Skip to content Skip to sidebar Skip to footer

Cgi - Html To Python

I am following the tutorial CGI, when I try to execute the program #!C:/Python27/python.exe # Import modules for CGI handling import cgi, cgitb # Create instance of FieldStorag

Solution 1:

If I understand correctly, you are saying that the web server is displaying the source of your Python program instead of executing the source. Based on your shebang specification, it appears you are running under Windows. Depending on what web server you are using, IIS or Apache for example, you need to configure the web server so that it knows that files with .py extensions are to be executed by the Python interpreter for it is clearly ignoring the shebang specification. For example, if using Apache your httpd configuration file might contain the following lines:

AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict

With the second line, the web server will ignore the shebang and use whatever program is associated with the filetype .py, which should be your Python interpreter. This is probably what you want as you may be upgrading your interpreter and its location changing. In this case you should probably code the shebang as:

#!/usr/bin/env python

Post a Comment for "Cgi - Html To Python"