Hey, I've recently signed up, joining Server 3, and I'm struggling to get past a 500 internal server error on a Python CGI script.
The HTML file (not that it could really be this) -
<html>
<head>
<title>Test</title>
</head>
<p>
<form action="cgi-bin/query.cgi" method="GET">
<input type="text" name="search">
<input type="submit" name="Submit"></form>
</body>
</html>
The CGI file -
#!/usr/bin/python
import cgi
print "Content-type: text/html"
print
print
print "<HTML><H1>Hello</H1></HTML>"
They both very basic because at this stage I can't even get that to work. I've applied chmod 755, searched around a good deal, but can't seem to find anything to help me.
If this is as basic as I think it must be I apologise, but thanks to anyone who can help me.
If it helps, I've found that the error log says that there is a 'Premature end of script headers'.
Any replies at all are welcome.
Does the error occur when you click submit or when you load the page?
When I've hit 'Submit' - I really think it should be an error with the cgi file, rather than the HTML file.
Calling the CGI file directly should work if it were just the HTML file, but that doesn't work either.
Okay, I've now worked out that there are cgi scripts that work on another host I'm using, but not FriHost. This means that it's not the script itself, but something unique to FriHost - the .htaccess file or something similar.
Anything? Anyone? Thanks again.
I dont know Python ...
... but I do not know what the reason of cgi library in your script? Perhaps the the script works in removing the import.
After Content-type there should be two blank lines. Does the print function insert these lines? Or should be printlln?
Bye 
Yeah, no, Python cgi scripts do need to import that library, and the print function does insert the required blank lines.
I've now become aware that others - http://www.frihost.com/forums/vt-98189.html - are having issues with Python on Server 3 - http://www.frihost.com/forums/vt-97899.html - and so this is a more general problem than just me.
That's good, or bad, depending on which way you look at it.
Try this
print "Content-type: text/html"
print "\r\n\r\n"
I did try that, and it still didn't fix the problem - but as I've already said, it could be Server 3 in general, and shouldn't be my script itself anyway since I can get it succesfully working on another service.
And carriage returns shouldn't be an issue, since I have tried just editting it in the online text editor, still to no avail.
Thanks for your suggestion though.
try running the same on your personal computer. see what kind of HTML it generates. may be try it on server in a shell.
run python script.py and you might spot some problem
Ah....thanks to those who keep replying, but this issue is kind of over, since I've now decided that it's Server 3 not having Python, rather than anything that I've done, being the source of the problem.
did you manage to get your account moved to a different host ? i am trying to do the same. i have sent message to bondings but no reply so far.
Hey,
No, my account hasn't been moved. As you said - http://www.frihost.com/forums/viewtopic.php?p=830832 - it doesn't look like account changes are being looked at.
Here - http://www.frihost.com/forums/vt-99805.html and http://www.frihost.com/forums/vp-823337.html - it is in fact said that server changes aren't possible. You've probably seen one or both of those, but for the benefit of others reading this I'm listing it anyway.
finally, no need to move the account to any other server. I can confirm that Python is now working on server 3. bondings installed it few days back. you just need to put your script in cgi-bin directory.
Following works for me.
1. create a file tes.py in public_html/cgi-bin directory
2. put following in a file test.py
| Code: |
#! /usr/bin/env python
print "Content-type: text/html"
print
print "<html>"
print "<center>Hello, Pythonic World....</center>"
print "</html>"
|
3. change the permission to 755 and. call the script in the browser and there you have it.
I'm still getting an error, but hunting around I did find - http://www.frihost.com/forums/vt-98631.html - bondings talking about it. Maybe I just need to sit down and bang my head against it again for a few hours, but I'm kind of reluctant given all the trouble I've had in the past.
And just while we're here - a few days? Try beginning of December. Given the number of people that were coming up against this problem, I'm surprised that this didn't come up in this topic until now.