wojiaoliming Posted March 7, 2020 Posted March 7, 2020 I want to run a python script, but I didn't find the right entry,can you help me ,tks
BlueyEmperor Posted March 7, 2020 Posted March 7, 2020 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.
wojiaoliming Posted March 8, 2020 Author Posted March 8, 2020 (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 butI followed your steps and changed the permissions to 777, but he still doesn't workthe demo at : http://help.heliohost.org/cgi-bin/test.py Edited March 8, 2020 by wojiaoliming
wojiaoliming Posted March 8, 2020 Author Posted March 8, 2020 You need to change the permissions to 755.Still 500 errorshelp me pls http://help.heliohost.org/cgi-bin/test.py
Krydos Posted March 8, 2020 Posted March 8, 2020 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>")
wojiaoliming Posted March 8, 2020 Author Posted March 8, 2020 Thank you, there should be a space after "#!" #! /usr/bin/python3.7 print("Content-Type: text/html\n\n") print("<h1>Test</h1>")
Krydos Posted March 8, 2020 Posted March 8, 2020 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.
BlueyEmperor Posted March 8, 2020 Posted March 8, 2020 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now