I can't seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn't work. I'm using Python 3.0 right now. Please don't recommend a WSGI framework as that is not what I'm looking for.
I would like to figure out how to get it into a fieldstorage object.
i would say WSGI application entry point is the wsgi.py script which is the Gate (stands also for Gateway) from apache into django app and vise versa. it is like browser < - > server < - > wsgi < - > django. without wsgi the server can serve (render) normal html files but not django app.
The server executes the web app and sends related information and a callback function to the app. The request is processed on the app side, and a response is sent back to the server utilizing the callback function. Sometimes there might be one or more WSGI middlewares between the server and the web app.
WSGI is a standard described on PEP 3333 and basically, provides a standard interface between web applications written in Python and Webservers. That means, WSGI gives portability to your Python Web Application across many different Web Servers, without any additional configurations on your NGINX, Apache, etc.
Assuming you are trying to get just the POST data into a FieldStorage object:
# env is the environment handed to you by the WSGI server. # I am removing the query string from the env before passing it to the # FieldStorage so we only have POST data in there. post_env = env.copy() post_env['QUERY_STRING'] = '' post = cgi.FieldStorage( fp=env['wsgi.input'], environ=post_env, keep_blank_values=True )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With