![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jan 2008
Posts: 31
Rep Power: 0
![]() |
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 ?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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/python import cgitb import cgi cgitb.enable() print "Content-type: text/html\r" print "\r" Depending 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. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jan 2008
Posts: 31
Rep Power: 0
![]() |
Re: Running python scripts on localhost
webserver means.... apache.exe ?
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Re: Running python scripts on localhost
Yes. (or IIS if you are using windows).
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
Re: Running python scripts on localhost
IR, why not use Apache for Windows?
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() ![]() |
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. ![]()
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#7 |
|
Programming Guru
![]() |
Re: Running python scripts on localhost
Gotchya. As long as we're clear on that.
![]() |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Jan 2008
Posts: 31
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#9 |
|
Programming Guru
![]() |
Re: Running python scripts on localhost
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. |
|
|
|
|
|
#10 | |
|
Programmer
Join Date: Jan 2008
Posts: 31
Rep Power: 0
![]() |
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. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| understanding scripts | Special T | Delphi | 0 | Oct 24th, 2006 8:26 PM |
| How to run Python scripts in a browser window | titaniumdecoy | Python | 6 | Jun 30th, 2006 2:39 AM |
| [tutorial] Python for programming beginners | coldDeath | Python | 30 | Dec 14th, 2005 11:35 AM |
| Anyone ever see an assembly program that could run python scripts? | Datalisk | Python | 5 | Oct 23rd, 2005 10:37 AM |
| Python - A Programmers Introduction | coldDeath | Python | 17 | Aug 19th, 2005 12:41 PM |