BaseHTTPServer module

A

amfr

From the BaseHTTPServer module, how do i gget the POST or GET data sent
by the client? Is it stired the the file they requested? e.g.
objectname.path
 
T

Tim Roberts

amfr said:
by the client? Is it stired the the file they requested? e.g.
objectname.path

Did you check the documentation in the module? You need to derive your own
class from BaseHTTPServer. In that module, you need to add functions
called do_GET and do_POST.

In a GET request, the data is all encoded in the URL. You'll find that in
self.path.

In a POST request, the data is all encoded in the body of the request.
You'll find that in self.rfile. You'll have to parse and decode it
yourself.

However, as the module documentation also tells you, that has already been
done for you in SimpleHTTPServer.py.
 
A

amfr

I looked at the doumentation and is says rfile is:
"Contains an input stream, positioned at the start of the optional
input data."
How do i get the input out of it?
 
P

Peter Hansen

amfr said:
I looked at the doumentation and is says rfile is:
"Contains an input stream, positioned at the start of the optional
input data."
How do i get the input out of it?

As with any "input stream" (file-like object) in Python, you call file
methods like .read() or maybe .readline() and others.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,271
Messages
2,571,361
Members
48,043
Latest member
BartEaster

Latest Threads

Top