|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
cgi test script to check server
I am having problems implementing a Python script that works on my pc, but get an internal server error or just displays as text on the web server.(The internal Server error says "Premature end of script header" in the error log.
The server is equiped with Python 1.5.2(trying to get them to upgrade) @ #!/usr/lib/python. http://www.haystar.com/cgi-bin/demreq.py http://www.haystar.com/scgi-bin/demreq.py Anybody have a suggestion on a simple test script to see if Python is even kicking off. Thanks, Brett |
|
#2
|
||||
|
||||
|
This error happens so often you would have thought more documentation on this error would be around. Anyway what this means is that your program is sending a bad header to Apache.
Make sure you are putting any raw data before you're headers and that there is a blank line after your headers and it should be fine .Mark. |
|
#3
|
|||
|
|||
|
I don't have a header() method in my code. Does this mean it needs one?
I am trying to read up on headers...I don't exactly know what they are and what purpose they serve. |
|
#4
|
|||
|
|||
|
Try putting
Code:
print 'Content-Type: text/html\n' after Code:
#/usr/lib/python |
|
#5
|
||||
|
||||
|
No, you don't need a header method(). infact this has nothing to do with Python as such. In any CGI program you send headers to the server and the browser so that the software knows what to do i.e. whether the document is html or text. This is done by printing a string that the software understands...
Code:
#!/usr/bin/env python print 'Content-Type: text/html\n' #Conent type header. print '<b>Hello Wold</b>' Will render a html document which says "Hello Wold" Code:
#!/usr/bin/env python print 'Content-Type: text/plain\n' #Conent type header. print '<b>Hello Wold</b>' will render a plain text document saying "<b>Hello Wold</b>\n" For more info on this subject check out this thread by roypython. http://forums.devshed.com/t127603/s.html or search this forum .Mark. |
|
#6
|
|||
|
|||
|
OK. had that. Thanks for the info on headers. I really want to use Python and learn it more, but I don't know if I will sense I got a Perl script to work with the form in 30 minutes.
![]() |
|
#7
|
|||
|
|||
|
Python is way better. You're just starting to learn, that's all. Take care!
|
|
#8
|
||||
|
||||
|
Agreeing with chief; as a language Python outshines perl at nearly every turn! In both clarity and power. However perls CGI package is amazing and Python seems to have been left behind in this respect. Chooseing to turn its attention to other aeas
.I'm actually working on my own module to make CGI in python easier but it's still in a beta state. Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > cgi test script to check server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|