How To Run Python Script On My Server?
I have a server hosting by Blueshot. I have been using php to get post variables from iPhone... But now I have to use python to get post variable from iPhone. I wrote something lik
Solution 1:
Here's a small checklist of things to check when CGI scripts aren't working:
- Is it in a
cgi-bin
(or equivalent) folder? - Is it executable?
- Is it readable?
- Does it have a hashbang?
- Is your server set up to process CGI scripts?
Here's a sample CGI script you can use for testing:
#!/usr/bin/env pythonimport cgi; cgi.test()
Name it test.py
, put it somewhere in cgi-bin
, and make sure it's executable:
$ chmod a+rx test.py
Some web servers only recognize CGI scripts with certain extensions, so if .py
doesn't work, you may want to try .cgi
.
Solution 2:
This is a webserver configuration problem not a programming issue.
If you're running Apache, this might work:
chmod 755 myscript.py
ln -s myscript.py myscript.cgi
Then put this in your .htaccess file:
AddHandler cgi-script .cgi
If you can't run the ln
command because of no shell access, just upload with the .cgi extension to begin with. Or, as icktoofay said, put it in your cgi-bin folder, then you won't need the .htaccess modification either.
Post a Comment for "How To Run Python Script On My Server?"