pythoncgimongoose-web-server

Running Python Scripts in Mongoose


I want to run python scripts on the mongoose web server. It worked fine with php-cgi.exe but not with python.exe.

Test script test.py:

print("Content-Type: text/html")
print("")
print("<h1>Hello World!</h1>")

Mongoose configuration mongoose.conf:

m .py=text/html
c py
I C:\\python\\python.exe

I've tried the script from the command prompt and it correctly returns:

Content-Type: text/html

<h1>Hello World!</h1>

Calling up http://localhost/test.py returns the following:

print("Content-Type: text/html")
print("")
print("<h1>Hello World!</h1>")

So the python code is not being interpreted and no errors are logged.


Solution

  • Solved: the mongoose.conf file is case sensitive. The following line is incorrect:

    c py

    it should be

    C py

    I can also confirm it works without #!python.exe or #!c:\python33\python.exe. How? Maybe mongoose is hard-wired to run python.exe when it sees a .py file and python.exe is in my PATH.