Jump to content

Recommended Posts

Posted

To run a Python script, place your .py file in the cgi-bin folder. It is also important to include the shebang line, which in your case would be #!/usr/bin/python3.7 for Tommy.

 

A simple script looks like:

#!/usr/bin/python3.7

print("Content-Type: text/html\n")
print("<h1>Test</h1>")

Hopefully this helps you.

Posted (edited)

To run a Python script, place your .py file in the cgi-bin folder. It is also important to include the shebang line, which in your case would be #!/usr/bin/python3.7 for Tommy.

 

A simple script looks like:

#!/usr/bin/python3.7

print("Content-Type: text/html\n")
print("<h1>Test</h1>")

Hopefully this helps you.

thanks very much 

but

I followed your steps and changed the permissions to 777, but he still doesn't work

the demo at : http://help.heliohost.org/cgi-bin/test.py

Edited by wojiaoliming
Posted

In order for python cgi to not give a 500 error one of the things you need is a content-type header followed by a blank line. Your test.py doesn't have this header.

 

 

#!/usr/bin/python3.7

print("Content-Type: text/html\n\n")
print("<h1>Test</h1>")

 

Posted

It will work with or without the space. I've always done my shebang without a space, and I believe most people do the same.

Posted

It will work with or without the space.

The exact example that I posted works fine for me, so the addition of a space would make no difference, as Krydos mentioned.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...