Skip to content

Some things I miss... #61

@flusflas

Description

@flusflas

Hi!

I'm using Picoweb and it's great. However, I'm feeling that it lacks of some minor features and convenience methods. I'm working on these features as I need them in my project, and I think my work or ideas might be useful to improve Picoweb. These are my thoughts so far:

  1. Request method filtering. Flask uses the route() function for it. I've created a decorator function to handle this.
  2. Manage exceptions in views. Although Picoweb handles the exceptions, I like to send a custom (500) response. Right now I am using the same methods decorator that I created, although it is not an ideal solution.
  3. A simple response class or method to avoid using the StreamWriter directly. I've created a Response class to send simple text/html and application/json responses. I've also created a subclass that format the response based on the JSend specification, although this is a very personal feature.
  4. I miss a body attribute in the request object (or a read() method), although there is a read_form_data() method (only useful with web forms). A json() method would also be great :)
  5. If a request has some body content but it is not read in the view (it may be not necessary), then the server doesn't send any response. That's why I think a body attribute could also help to empty and close the reader stream before the handler is called.

I've solved all of these needs, and I can adapt my code into Picoweb and make a few pull requests. However, I wanted to know what do you think about these features and if it makes sense to include them into the library.

Thank you, and sorry if my English doesn't make sense sometimes...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions