Wie führe ich ein Python-Skript auf dem von Python erstellten BaseHTTPSERVER aus?

Ich habe einfach einen Python-Server erstellt mit:

python -m SimpleHTTPServer

Ich hatte ein .htaccess (ich weiß nicht, ob es mit Python-Server nützlich ist) mit:

AddHandler cgi-script .py
Options +ExecCGI

Jetzt schreibe ich ein einfaches Python-Skript:

#!/usr/bin/python
import cgitb
cgitb.enable()
print 'Content-type: text/html'
print '''
<html>
     <head>
          <title>My website</title>
     </head>
     <body>
          <p>Here I am</p>
     </body>
</html>
'''

Ich mache test.py (Name meines Skripts) zu einer ausgeführten Datei mit:

chmod +x test.py

Ich starte in Firefox mit dieser Adresse: (http: //) 0.0.0.0:8000/test.py

Problem, das Skript wird nicht ausgeführt ... Ich sehe den Code auf der Webseite ... Und der Serverfehler ist:

localhost - - [25/Oct/2012 10:47:12] "GET / HTTP/1.1" 200 -
localhost - - [25/Oct/2012 10:47:13] code 404, message File not found
localhost - - [25/Oct/2012 10:47:13] "GET /favicon.ico HTTP/1.1" 404 -

Wie kann ich die Ausführung von Python-Code einfach verwalten? Ist es möglich, in einen Python-Server zu schreiben, um das Python-Skript wie folgt auszuführen:

import BaseHTTPServer
import CGIHTTPServer
httpd = BaseHTTPServer.HTTPServer(\
    ('localhost', 8123), \
CGIHTTPServer.CGIHTTPRequestHandler)
###  here some code to say, hey please execute python script on the webserver... ;-)
httpd.serve_forever()

Oder etwas anderes...

Antworten auf die Frage(2)

Ihre Antwort auf die Frage