Newbie question about a web server

Chris Allen ca.allen at
Mon Aug 20 23:47:56 CEST 2007

On Aug 20, 12:02 am, Frank Millman <fr... at> wrote:
> Hi all
> I have just started to dabble in writing my own web server.
> I googled for 'python web server', and this is the first hit -
> It has the source code for a simple web server, based on HTTPServer
> and BaseHTTPRequestHandler.
> It demonstrates the concepts of
>   - returning a static page
>   - constructing and returning a dynamic page
>   - sending a form with a POST method, and responding to the result
> I typed it in and ran it, and it 'just worked', with one exception.
> When responding to the initial request, it sends a 200 response,
> followed by a content-type header, followed by an html page. This
> works fine.
> When responding to the POST data received, it sends a 301 response, no
> headers, and then the html page.
> This works with a Firefox browser on Linux, but MSW IE6 displays 'the
> page cannot be displayed'.
> According to the notes, "You don't have to know much about the HTTP
> protocol at all. Except some basic that when the client request
> something it is a "GET", and when the client sends something it is in
> our case a POST. Some basic responce codes like 200 is OK for GET, and
> 404 is file not found, 301 is OK for a Post."
> I googled for 'http response code 301', and found that it is actually
> a redirection code. It seems that the notes are misleading.
> So I guess my questions are -
>   1. what is the correct response for a POST?
>      I think the answer is 200.
>      However, I assume the author is trying to demonstrate a
> particular technique.
>      Can anyone explain what that may be.
>   2. why does the above work with Firefox?
> TIA for any enlightenment.
> Frank Millman

Yes HTTP response code 200 does indicate a normal response.  What you
really need to look at to build an HTTP server is is the RFC for
HTTP.  It is HTTP 1.1 is RFC 2616 and you can view it here:

That should get you on your way...

More information about the Python-list mailing list