-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling for POST parameters #15
Comments
I'm not an expert on these things, but it does seem the But I do like the idea of something like a helper method at the very least, so you can just something and out pops your POST params. Maybe something that will copy I had to manually do this as well for my own project, I feel you. Want to submit a PR for this? |
Probably not until there's some more buy in on how it should be implemented.
Could make a if self._method == "POST":
self._post_params = self.__parse_query_params(self._body.getvalue())
else:
self._post_params = {} Not sure if My preference would lean toward computing it lazily on first access of a property like: @property
def post_params(self) -> Dict[str, str]:
if not self._post_params:
if self._method == "POST":
self._post_params = self.__parse_query_params(self._body.getvalue())
else:
self._post_params = {}
return self._post_params
|
We now recommend using https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer instead, and would like to discontinue supporting this library. Would that library meet your needs? Maybe it already addresses what you would like here? |
I will look into it. |
Likewise. I know several libraries I was & am using have moved around, so I need to cut a new version that incorporates them and see what's working in the new versions. |
@dhalbert I think this could use a migration guide. I'm not sure how https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer is intended to replace WSGI. adafruit/Adafruit_CircuitPython_Wiznet5k#160 killed the Wiznet WSGI server and suggested https://github.com/adafruit/Adafruit_CircuitPython_WSGI was an alternative, but as far as I can tell, From your comment, you want to remove/deprecate |
I saw this example code for handling POST requests in another issue:
It looks pretty straightforward, but when I tried it, it doesn't work.
query_params
only has the parameters from the query string; the POST parameters are in the request body as one might expect.My working code looks like this:
I can reuse the
__parse_query_params()
logic, but it's a little less intuitive than the first example would suggest. Perhaps this could be improved? Shouldquery_params
contain request body parameters for POST requests? Maybe it should be a different collection, or only parse the request body on demand.The text was updated successfully, but these errors were encountered: