469,328 Members | 1,271 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

BaseHTTPServer module

>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

Nov 22 '05 #1
4 3328
"amfr" <am******@gmail.com> wrote:
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


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.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 22 '05 #2
"amfr" <am******@gmail.com> wrote:
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


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.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 22 '05 #3
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?

Dec 1 '05 #4
amfr wrote:
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

Dec 1 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Yin | last post: by
2 posts views Thread by Simon Wittber | last post: by
2 posts views Thread by Andy Leszczynski | last post: by
1 post views Thread by Adam Atlas | last post: by
reply views Thread by amfr | last post: by
reply views Thread by Ron Garret | last post: by
13 posts views Thread by Ron Garret | last post: by
3 posts views Thread by Ron Garret | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.