
Ich arbeite momentan das Buch "OOP mit Pyhton" von Michael Weigend durch, welches vielleicht bekannt ist. Ich bin mittlerweile bei CGI Skripte angekommen und hab das Problem, dass ich gerade nicht weiss warum er das macht, was er macht

Code: Alles auswählen
# httpd.py
import CGIHTTPServer, BaseHTTPServer
httpd = BaseHTTPServer.HTTPServer(("", 8000), CGIHTTPServer.CGIHTTPRequestHandler)
httpd.serve_forever()
Code: Alles auswählen
#!/usr/bin/python2.4
# from time import *
# z = localtime()
print 'Content-Type: text/html'
print ''
print '<html><body>'
print 'Hello world'
print '</body></html>'
So funktioniert das alles, und ich sehe ein tolles "Hello world" im Browser.
Wenn ich aber das # vor dem 'from time import *' lösche kommt folgendes ->
Hello world Content-Type: text/html Hello world
Wenn ich 'z = localtime' mit in den code schreibe zeigt der Browser nur ne weisse Seite an.
Was hab ich da übersehen ? Bzw was stimmt da nicht ?
Vielen Dank schonmal
mfg mac
GNU/Linux (archlinux) / Python 2.4.1/ Firefox 1.0.1