Python HTTP-Server / CGI Skript
Verfasst: Dienstag 12. April 2005, 19:05
Erstmal ein Hallo, an alle im Forum
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
. Hier erstmal die beiden Skripte:
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 ->
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

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>'
Wenn ich aber das # vor dem 'from time import *' lösche kommt folgendes ->
Wenn ich 'z = localtime' mit in den code schreibe zeigt der Browser nur ne weisse Seite an.Hello world Content-Type: text/html Hello world
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