A nice nuts and bolts approach is:
FWIW, for a POST request you have to read request content and parse
out form arguments. Toolkits like above do this for you and why you
probably want to use one of them.
Graham
2008/6/25 Wyatt Biker <wyatt...@gmail.com>:
They are in the response body. To retrieve them you use the file like
object in environ['wsgi.input']:
# app.wsgi
from urllib import unquote_plus
def application(environ, start_response):
body = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
parameter_pairs = body.split('&')
parameter = dict()
for parameter_pair in parameter_pairs:
parameter_pair = parameter_pair.split('=')
parameter[unquote_plus(parameter_pair[0])] = \
unquote_plus(parameter_pair[1])
output = repr(parameter)
status = '200 OK'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
In addition to the id parameter in the input tags you must also use a
name parameter:
Name : <input id="name" name="name" type="text" value="John Doe">
Obviously it would be much easier to use modules or middeware provided
by a framework or something else not that heavy.
Regards, Clodoaldo
You can also use paste:
{{{
from paste import request
def application(environ, start_response):
if (environ['REQUEST_METHOD'] == 'POST):
fields = request.parse_formvars(environ)
field1 = fields.get('field1', 'default)
}}}
paste has more then a few convenience methods.