Reputation: 41
I have a web server and my cgi-bin is on 0755, and my script called return.py is also 0755. And when my script is just this
#!/usr/bin/perl
import cgi
import json
print "Content-type: text/plain\n\n";
print "testing...\n";
And I go to the web page I see testing... as I should, but when I add any of this to my script
form = cgi.FieldStorage()
param = form.getvalue("param")
if param:
json.dumps({'success': True, 'message': param })
else:
json.dumps({'success': False, 'message': 'did not receive parameter' })
I get a 500 Internal Server Error, and Im not sure why, I have the correct permissions set, and the python is running because it works when I don't add the stuff above? Is there something wrong with my above code? What else could be causing this issue?
BY THE WAY the above code is because I am making a POST to this and what to return the value posted. Just a simple test case, but I can't get it to work?
Ive gone through this check list, of what I could check, and it all worked https://encodable.com/internal_server_error/
Thanks for the help in advance. :)
EDIT
here are error logs
[Tue Jun 23 01:35:38.661161 2015] [authz_core:error] [pid 874653] [client 173.34------:51484] AH01630: client denied by server configuration: /home/spencer/public_html/.htaccess
[Tue Jun 23 01:35:38.426745 2015] [access_compat:error] [pid 874653] [client 173.34-----:51484] AH01797: client denied by server configuration: /home/spencer/public_html/error_log
Upvotes: 0
Views: 1073
Reputation: 2783
Just change the shebang and it should work
#!/usr/bin/perl
import cgi
import json
print "Content-type: text/plain\n\n";
print "testing...\n";
and assuming u save it as test.py works then u add below part
#!/usr/bin/perl
import cgi
import json
print "Content-type: text/plain\n\n";
print "testing...\n";
form = cgi.FieldStorage()
param = form.getvalue("param")
if param:
json.dumps({'success': True, 'message': param })
else:
json.dumps({'success': False, 'message': 'did not receive parameter' })
it gives server error
Then change the shebang to
#!/usr/bin/python
And it works .....put correct shebang and life is easy
Upvotes: 1