[Tutor] Handling post request

Tiago Katcipis katcipis at inf.ufsc.br
Wed Jan 28 12:33:01 CET 2009


thank you all for the help but i have finnaly been able to do what i wanted.
I will not use CGI scripts, its very simple what im doing and i just wanted
the parameters sent on the POST like:
*
"name1=value1&name2=value2&name3=value3"*

but reading about CGI i discovered that the size of these parameters are in
content-lenght, when reading the rfile with the content-length as the number
of bytes to read it has worked fine.

best regards

On Wed, Jan 28, 2009 at 9:20 AM, Justin Ezequiel <
justin.mailinglists at gmail.com> wrote:

> > From: Tiago Katcipis <katcipis at inf.ufsc.br>
> >
> > I am trying to make a small HTTP server on python just to handle some
> POST
> > and GET requests. I never worked with http before and dont know if i am
> > doing something completely stupid (probably yes). I read anything
> possible
> > already and i just cant find how i access the information sent on the
> POST
> > request, i need these because some parameters needed by the server must
> be
> > sent on the POST request, my client test does this:
> >
> >
> > f = urllib2.urlopen(url,  urllib.urlencode('http://my_server_adress:port
> ',
> > {'Teste' : 'teste', 'Teste2' : 't2', 'Teste3' : 't3'}))
> > f.close()
> >
> > The server runs ok and receives the POST request just fine, but im not
> > finding where the data that i have sent on the post request is being
> held.
> > Sorry if the question is extremely stupid, i really tried a lot of things
> > already and read a lot, maybe i just have let something pass when i was
> > reading or i am understanding something terribly wrong :-(.
>
> Hello, I needed to do the same recently to test my scripts that do GET
> and POST to a web site.
> Found how to get at the posted data within CGIHTTPServer.py
> particularly the run_cgi method of the CGIHTTPRequestHandler class.
>
> At first I just ran an instance of the CGIHTTPServer and had a few CGI
> scripts until I read the code for the run_cgi method above.
> Now my test script runs an HTTP server in a daemon thread using my
> subclass of the CGIHTTPRequestHandler then the main thread then runs
> my GET and POST code.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
"it might be a profitable thing to learn Java, but it has no intellectual
value whatsoever" Alexander Stepanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090128/c289adc5/attachment-0001.htm>


More information about the Tutor mailing list