Running a Python Script on a server (Does it have to be in /cgi-bin/)?
Right now I have a script thats
http://www.example.com/cgi-bin/foo?var1=A&var2=B
Is there a way that I can have it run outside of the cgi-bin directory? Like could I have
http://www.example.com/foo/?var1=A&var2=B开发者_Go百科
In Apache you can change the directories that can contain executable scripts with the ScriptAlias
directive in httpd.conf (or whatever file holds your configuration).
You can also use mod_rewrite to rewrite URLs to point to the scripts you want to execute. Mod_rewrite also allows you to pass variables and stuff in the form of URLs if you like that, e.g.
www.example.com/foo/A/B/ -> www.example.com/foo?var1=A&var2=B
Short answer, yes. I'm no expert on this, but I know of a number of frameworks that do exactly what you just did (e.g. Ruby on Rails). A lot of it has to do with how your server routes URLs. Try looking up the documentation on your server.
精彩评论