Does parse_header really belong to cgi?

http://bugs.python.org/issue3609

Barry's thought is it can be moved to email module.

Bugs Fixed

Fixed Bugs:
http://bugs.python.org/issue4675
http://bugs.python.org/issue4962

Simple CGIHTTPServer and Client in Python 3k

Python 3k - CGIHTTPRequestHandler example.


import http.server
import http.server

class Handler(http.server.CGIHTTPRequestHandler):
cgi_directories = ["/cgi"]

server = http.server.HTTPServer(("",8000),Handler)
server.serve_forever()


Run this server.

Create a Directory 'cgi' in the directory you have the above server script and place the following python cgi code.

filename: test.py

#!/usr/local/bin/python3.1

import cgitb;cgitb.enable()

print("Content-type: text/html")
print()
print("<title>CGI 101</title>")
print("<h1>First CGI Example</h1>")
print("<p>Hello, CGI World!</p>")



Open the Browser and point to http://localhost:8000/cgi/test.py

file opening modes.

Possible values for the mode open are

"r" or "rt"
Open for reading in text mode.
"w" or "wt"
Open for writing in text mode.
"a" or "at"
Open for appending in text mode.
"rb"
Open for reading in binary mode.
"wb"
Open for writing in binary mode.
"ab"
Open for appending in binary mode.
"r+", "r+b"
Open for reading and writing.
"w+", "w+b"
Open for reading and writing, truncating file initially.
"a+", "a+b"
Open for reading and appending.