•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,472 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,795 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 1017 | Replies: 5 | Solved
![]() |
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
I know there have been several posts concerning Python and CGI / HTML, but I can't get my little script to even print a web page.
I get a '500 server error' when I try to run this through a web server, but it runs without errors on my command line.
The file permissions are rwxr-xr-x.
I've posted in comp.lang.python but haven't found a solution there.
The script does not create a log file in the current directory either.
Can someone here point out why this may not be working?
#!/usr/bin/python print "Content-Type: text/html\n\n" print import sys sys.stderr = sys.stdout import cgitb; cgitb.enable(display=0, logdir=".") print """ <html> <body> <div align="center"><font style="font-family:verdana; font-size:18px">Hello from Python</font></div> <br> Goodbye. </body> </html>"""
I get a '500 server error' when I try to run this through a web server, but it runs without errors on my command line.
The file permissions are rwxr-xr-x.
I've posted in comp.lang.python but haven't found a solution there.
The script does not create a log file in the current directory either.
Can someone here point out why this may not be working?
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
•
•
•
•
You may need \r\n at the end of your lines instead of just \n.
Have you looked into PyWeb, which is designed to do what you want? I can't speak to how well it does what you want, but surely it merits a look.
Thanks for the reply. I tried your suggestion, but same results. Even removed them completely from the print statement.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
The solution to my problem of not being able to execute a simple Python script on my hosting server is slightly embarrassing. It seems that while Python itself is installed, the Apache module needed to make it available through a web server is not. DUH!
This only came about after some digging on my part, and eventually I talked with one of the techs at the server farm.
The good news is that I did get it to work on my home PC, after putting the right path in the shebang line. Another slight embarrassment. Ah well, who says old dogs can't learn new tricks.
This only came about after some digging on my part, and eventually I talked with one of the techs at the server farm.
The good news is that I did get it to work on my home PC, after putting the right path in the shebang line. Another slight embarrassment. Ah well, who says old dogs can't learn new tricks.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
•
•
•
•
Good to hear things are working.
What's the name of the Apache module and where did you find it? I may be trying to do the same thing in a couple of months.
I didn't need to add any modules to my home PC - once I had the right path to Python in my script, it worked fine. Just make sure it goes in or under cgi-bin or whatever you have for executables.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Why should i learn Python? (Python)
- html table cell coloring (JSP)
- Python with SWIG on WindowsXP platform (Python)
- Generating HTML - View Source in Firefox (PHP)
- Generation html in perl (Perl)
- How to add printing features (Perl)
Other Threads in the Python Forum
- Previous Thread: newbee: simple python for loop question
- Next Thread: Average Word Length


Linear Mode