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 Quote
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. Quote
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 Quote
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 Quote
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>") Quote
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>") Quote
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. Quote
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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.