minus11 Posted September 28, 2014 Posted September 28, 2014 Hi all, I am trying to write my first CGI script using Python on my shared virtual web server. I put the script under 'public_html' in the 'cgi-bin' folder on my web server. I made the script executable with the chmod +x command. For the she-bang I am using #! /usr/bin/env python so that the script will be able to find any Python interpreter and not a specific one at a specific location. I made a test form to call the script from when a button is clicked but I just receive a 500 Internal Server error when trying to run this script. I messed around some with the location of the cgi script, which is a .py file in this case, but only received 404 errors. Does anyone reading this know what I am missing? Here is my Python script: #! /usr/bin/env python print "Content-type:text/html\r\n\r\n" print '<html>' print '<head>' print '<title>Hello Word - First CGI Program</title>' print '</head>' print '<body>' print '<h2>Hello Word! This is my third or fourth or so CGI program</h2>' print '</body>' print '</html>' Here is my HTML code that calls the Python script: <!DOCTYPE html> <head> <title>Test CGI Scripting With Python</title> </head> <body> <center> <form action="cgi-bin/hello.py" method="post"> Click this button <input type="submit" value="Submit" /> </form> </center> </body> </html> Thank-you for reading this everybody. Respectfully, minus
Ice IT Support Posted September 29, 2014 Posted September 29, 2014 Please provide a link to the script and the server you are on.
minus11 Posted October 5, 2014 Author Posted October 5, 2014 Please provide a link to the script and the server you are on. Hi, Thank-you for the tech support. Here is a direct link to the script: http://badvibesforcefield.heliohost.org/cgi-bin/hello.py This results in a 500 "Internal Server Error" though. I am on the Johnny server. Regards, minus
Ice IT Support Posted October 6, 2014 Posted October 6, 2014 Your shebang line should be #!/usr/bin/python on HelioHost. Sorry I didn't notice that earlier.
minus11 Posted October 26, 2014 Author Posted October 26, 2014 Cool. Thank-you for the help. I will try this shebang. Actually, I just changed the she-bang and still receive a 500 Internal Error. :/
minus11 Posted November 28, 2014 Author Posted November 28, 2014 I figured out my coding problem. I had to set the permissions to 0755! This was in addition to the other change of specifying the exact path to the python interpreter.
yashrs Posted November 29, 2014 Posted November 29, 2014 Great that you figured that out ! Let us know if you need any other help.
To175 Posted January 7, 2015 Posted January 7, 2015 Hello, same problem #!/usr/bin/python print "Bienvenue sur mon site web !" http://mecraft.fr/cgi-bin/hello.py 0755 ! Help me please :/
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