zonedabone Posted June 28, 2010 Posted June 28, 2010 Hey, everyone. This probably makes me look stupid, but I just don't get how to use python in pages. I get that you make the file in the cgi-bin folder, and add the shebang and header type, but then how do you make this run when you go to a certain page? For example, if you go to eap17.heliohost.org/myprog I want it to run the python script. how do I do that?
Guest Geoff Posted June 28, 2010 Posted June 28, 2010 Hey, everyone. This probably makes me look stupid, but I just don't get how to use python in pages. I get that you make the file in the cgi-bin folder, and add the shebang and header type, but then how do you make this run when you go to a certain page? For example, if you go to eap17.heliohost.org/myprog I want it to run the python script. how do I do that? If you want to include a dynamic page anywhere in your site, you are probably better off using php. However there are two ways to run the python script from another URL. You can also just run it directly. You can go to http://your-url.heliohost.org/cgi-bin/your-python-file.pyYou can create an ".htaccess" file in your public_html folder, or edit the one that you already have in their, and add the following lines: Options +ExecCGI AddHandler cgi-script cgi py Then you don't have to put your python files in cgi-bin to run them.You can Add a rewrite rule to ".htaccess" to rewrite "http://eap17.heliohost.org/myprog" to "http://eap17.heliohost.org/cgi-bin/myprog.py" RewriteEngine on RewriteRule ^myprog$ \/cgi-bin\/myprog.py
zonedabone Posted June 29, 2010 Author Posted June 29, 2010 Ok. Thanks. I'll try some of it. =) I just tried it! It all works great! One thing I forgot to do was set the permissions correctly. Silly me. Thank you so much for the help! I did the rewrite rule and everything. If you want to see my (splendid) piece of python testing, you can go to eap17.heliohost.org/cgi-bin/testprog.py or eap17.heliohost.org/myprog. Thanks so much, again! I'm learning python over the summer, and I want to incorperate it into everything I do.
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