![]() |
Running python scripts on localhost
I am able to run the fibonacci.py on the activepython editor. But when i try to run a python script ( say webpagecounter.py) for localhost, the browser loads the script. How should i force browser to run that script ?
|
Re: Running python scripts on localhost
Well I'm going to assume you have everything necessary set up... such as the web server, CGI support, placed the script in the appropriate directory, linked the .py extention to the cgi-handler, etc...
Then, your code should start off with something like: :
#!c:/python24/pythonDepending on your CRLF, and location of Python. My example is if the web server is on Windows, with the Python interpreter at c:/python24/python.exe. |
Re: Running python scripts on localhost
webserver means.... apache.exe ?
|
Re: Running python scripts on localhost
Yes. (or IIS if you are using windows).
|
Re: Running python scripts on localhost
IR, why not use Apache for Windows?
|
Re: Running python scripts on localhost
Sane... Personally, I would definitely run Apache across all supported platforms...
I guess my wording should have been more defined... I was merely pointing out that IIS was a web server option on the windows platform. For the record, I suggest using Apache. :) |
Re: Running python scripts on localhost
Gotchya. As long as we're clear on that. ;)
|
Re: Running python scripts on localhost
No luck....:(
I tried installing python mod for xampp. And again tried running fibonacci.py in htdocs. But it again loads the whole script instead of running it. Can anybody please figure out what is the problem. Why the browser is not able to detect the code and run it. |
Re: Running python scripts on localhost
Quote:
It has nothing to do with your browser. It has to do with a webserver which supports CGI capabilities with Python. First, make sure you have a webserver which is operational. This can be verified by visiting localhost and making sure you can see any files placed in the document root. Then, make sure you have Python installed. The first thing your script should do is point to the location of the Python interpeter (see the code I posted in the first reply). Finally, assert that you've configured your webserver to have CGI-support enabled for .py extentions. This process will vary depending on what webserver software you're using. It is well documented for Apache. |
Re: Running python scripts on localhost
Quote:
However most of the other scripts are still not running. Can anybody please help me ( or link me to) with a crude sample script like say a web counter, so that i may ensure everything is running fine. |
| All times are GMT -5. The time now is 4:44 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC