Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to run python cgi scripts using CGIHTTPRequestHandler in Python 3.3
    primarykey
    data
    text
    <p>I am a noob; trying to create and use a simple webserver in Python that executes CGI scripts written in Python. I am using Windows XP and Python v3.3.0. I have a "myserver" directory which contains "myserver.py","sample.html" and the directory "cgi-bin" which in turn contains "cgi_demo.py"</p> <p>myserver.py</p> <pre><code>from http.server import HTTPServer from http.server import CGIHTTPRequestHandler port = 8080 host = '127.0.0.1' server_address = (host,port) httpd = HTTPServer(server_address,CGIHTTPRequestHandler) print("Starting my web server on port "+str(port)) httpd.serve_forever() </code></pre> <p>cgi_demo.py</p> <pre><code>import cgi import cgitb; cgitb.enable() print("Content-type: text/html") print print("&lt;html&gt;&lt;body&gt;") for i in range(0,100): print(i,"&lt;br&gt;") print("&lt;/body&gt;&lt;/html&gt;") </code></pre> <p>Now the directory listing works fine for "myserver" but not for "cgi-bin"; maybe that is how it is coded - I don't have a problem here. "sample.html" is retrieved fine too. However, the execution of "cgi_demo.py" is not proper. I get a blank page in the browser; and the console window (which is blank too) appears and disappears. Moreover, on the server's console I get the message</p> <pre><code>127.0.0.1 - - [29/Nov/2012 12:00:31] "GET /cgi-bin/cgi_demo.py HTTP/1.1" 200 - 127.0.0.1 - - [29/Nov/2012 12:00:31] command: C:\Python33\python.exe -u "D:\python apps\my web server\cgi-bin\cgi_demo.py" "" 127.0.0.1 - - [29/Nov/2012 12:00:32] CGI script exited OK </code></pre> <p>Please tell me what is wrong! I get the feeling that the output stream of my script is not connected to the server. What am I doing wrong? Don't say that I have to extend CGIHTTPRequestHandler!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload