Jump to content

[Solved] how can i run a python Script


wojiaoliming

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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>")

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...