Wizard Posted January 31, 2010 Posted January 31, 2010 I am getting 500 internal server error for my .py/.cgi file. Did anyone find solution for 500 error? Lets see your code.
benetta Posted February 8, 2010 Posted February 8, 2010 I am getting 500 internal server error for my .py/.cgi file. Did anyone find solution for 500 error? Lets see your code. sorry for the late reply. My code is below: ************************************* #!/bin/bash cd `dirname $0` # ------------------------------------------------- choose a suitable Python pycheck() { python=$1 if ! $python -c '' 1>/dev/null 2>/dev/null; then version= mysqldb= return fi version=$($python -V 2>&1 | sed -e 's/^Python *//') mysqldb=$($python -c 'from MySQLdb import connect; print 1' 2>/dev/null) } collect() { candidate=$1 for element in ${array[*]}; do if [ $candidate == $element ]; then return; fi done array=(${array[@]} $candidate) } # Gather a list of likely directories for binaries, skipping duplicates. array=() for dir in $(echo $PATH | tr : ' '); do collect $dir done collect /bin collect /usr/bin collect /usr/local/bin # Find all the Python binaries in these directories. pythons=`find ${array[*]} -name "python*" -not -name "pythonw*" 2>/dev/null` # Check each Python binary for its version and the MySQLdb module. array=() adequate= first=1 for python in $pythons; do pycheck $python if [ -z "$version" ]; then continue; fi present=no if [ -n "$mysqldb" ]; then present=yes; fi good=" " if [[ ! "$version" < 2.3 ]]; then if [ -z "$adequate" ]; then adequate=$python fi if [ -n "$mysqldb" ]; then good="*" collect $python fi fi if [ -n "$first" ]; then echo "Looking for Python binaries on your PATH:" echo echo "Version MySQLdb Binary" first= fi # if [ -L $python ]; then python="$python -> "`readlink $python`; fi printf " %-6s %3s %s %s\n" $version $present "$good" "$python" done echo # Allow the user to choose a Python binary or accept the first good choice. echo 'Flamenco requires Python version 2.3 or higher with MySQLdb.' echo if [ -n "${array[0]}" ]; then echo 'In the above list, Python binaries marked with "*" meet both of' echo 'these criteria. (If you prefer, you can enter the path to any' echo 'Python binary that is at least version 2.3, and Flamenco setup' echo 'will attempt to build and install MySQLdb if it is missing.)' echo default=${array[0]} elif [ -n "$adequate" ]; then echo 'The Python binaries on your PATH are listed above, but none meet' echo 'both of these criteria. Enter the path to any Python binary that' echo 'is at least version 2.3. Flamenco setup will attempt to build and' echo 'install MySQLdb if it is missing.' echo default=$adequate elif [ -z "$first" ]; then echo 'The Python binaries on your PATH are listed above, but none are' echo 'version 2.3 or higher. If you have Python 2.3 or higher, enter' echo 'the path to the Python binary. Flamenco setup will attempt to' echo 'build and install MySQLdb if it is missing.' echo echo 'If you do not have Python version 2.3 or higher, press Ctrl-C to' echo 'abort Flamenco setup. Download Python from http://python.org/.' echo default= else echo 'However, no working Python binaries were found on your PATH.' echo 'If you have Python 2.3 or higher, enter the path to the Python' echo 'binary. Flamenco setup will attempt to build and install MySQLdb' echo 'if it is missing.' echo echo 'If you do not have Python version 2.3 or higher, press Ctrl-C to' echo 'abort Flamenco setup. Download Python from http://python.org/.' echo default= fi ........................ ************************************************************** It does not find python binary under /bin or /usr/bin or /usr/local/bin Where else would python binary (executable) reside ??
Leandro Arndt Posted February 12, 2010 Posted February 12, 2010 I found an interesting page on WSGI: http://pythonpaste.org/do-it-yourself-framework.html A basic Hello World program would seem like this: def application(environ, start_response): start_response("200 OK", [("Content-type", "text/html; charset=UTF-8")]) s = """<html> <head> <title>Hello, World!</title> </head> <body> HELLO, WORLD! </body> </html>""" return [s] I'm still going to use those tips on my Django powered sites, but this should be the way to go. BTW, one should add the wsgi middleware to one's Django settings (django.core.handlers.wsgi), I think.
fatboy Posted August 7, 2010 Posted August 7, 2010 Hi all, Was facing the same problem as everyone here with Python script returning a 500 server error and generally not working at all. Adding this extension under "Apache Handlers" in the cPanel fixed the whole thing Handler: cgi-script Extension(s): .py .cgi Just make sure that you include the PERIOD in front of the extensions otherwise it won't work! Edit: Well it worked for a little while and now over-night suddenly scripts that worked don't any more. I'm grateful for the free hosting but there is clearly something seriously wrong with the python setup on the server.
rwebdesign Posted September 15, 2010 Posted September 15, 2010 Hi, I am new to Helio Host and so far, I really like how clean and straightforward the site is compared to other free hosts. I think I am having the same problem as the author of this post and I would like to know if anyone has come up with a good response. I am learning python and am trying to upload/execute this script: (I used chmod +x (file name) to make it executable. #!/usr/bin/python print "Content-type: text/html" print """\ <html> <body> <h2>Hello World!</h2> </body> </html> """ Unfortunately, I am getting the 500 error or, if I add the handlers mentioned earlier in this thread, I can get a text file of the script, but not the executed output. This is what I've done: mod-python for .py ==> text version of the script cgi handler for .cgi .py ==> 500 error python-program for .py ==> text version of the script My site is at: http://rawat.heliohost.org/cgi-bin/script.py I would appreciate your help tremendously. Thanks
Wizard Posted September 15, 2010 Posted September 15, 2010 Works now. Probably was a problem with server load.
Sean Zhu Posted September 17, 2010 Posted September 17, 2010 It seems to work only sometimes. But I do notice that it seems work if and only if cPanel works. Solutions?
Sean Zhu Posted September 17, 2010 Posted September 17, 2010 It seems to work only sometimes. But I do notice that it seems work if and only if cPanel works. Solutions?
Wizard Posted September 17, 2010 Posted September 17, 2010 It seems to work only sometimes. But I do notice that it seems work if and only if cPanel works. Solutions? Well yeah, if the server has enough resources to run cPanel, it'll have enough resources to run your script. Read the Support FAQ.
TReX1983 Posted October 2, 2010 Posted October 2, 2010 It seems to work only sometimes. But I do notice that it seems work if and only if cPanel works. Solutions? Well yeah, if the server has enough resources to run cPanel, it'll have enough resources to run your script. Read the Support FAQ. Did anyone have any luck getting this to work consistently? I was on heliohost a about 7 months ago and everything was working like a charm. I can't get a simple python "hello world" to work now.
zonedabone Posted October 17, 2010 Posted October 17, 2010 I've been having the same problem, but I just found the solution in the 755! I'd been making py fils and such, but they wouldn't work, however, I was able to use this one file I had. realized that everything had to have 755 perms for execution. THis may be obvious, but check your files!
vipex Posted December 18, 2010 Posted December 18, 2010 Hmm... I new here and want to run Python code. It seem mostly have a problem with Python. Are they still working?
Byron Posted December 18, 2010 Posted December 18, 2010 Hmm... I new here and want to run Python code. It seem mostly have a problem with Python. Are they still working? It should be working. Django is working for me. http://byrondallas.heliohost.org/djangotest/dispatch.wsgi
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