Re: Apache Python 500 Error

2005-02-03 Thread Christian
Jeremy Bowers schrieb:
But first, check your apache error log. Then you will know what your error
is, too.
Thanks for help, here is my error log:
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python: Traceback (most 
recent call last):
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python:   File 
/usr/lib/python2.3/site-packages/mod_python/apache.py, line 181, in 
Dispatch\nmodule = import_module(module_name, _req)
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python:   File 
/usr/lib/python2.3/site-packages/mod_python/apache.py, line 335, in 
import_module\nmodule = imp.load_module(mname, f, p, d)
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python:   File 
/var/www/python/python.py, line 1
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python: from 
mod_python import apache
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python: ^
[Thu Feb  3 13:52:49 2005] [error] PythonHandler python: SyntaxError: 
invalid syntax


My test script:
#!/usr/bin/python
print 'Content-Type: text/plain\r'
print '\r'
import os
print os.getcwd()
thanks to Fuzzyman for test script
--
http://mail.python.org/mailman/listinfo/python-list


Re: Apache Python 500 Error

2005-02-03 Thread Peter van Kampen
On 2005-02-02, Christian [EMAIL PROTECTED] wrote:
 Hello,

 i have an apache 1.3 server with python on debian. Python works fine but 
   the scripts wont´t work.

 This easy script i want to do on apache:

 #!/usr/bin/python
 import os
 os.getcwd()

 in apache config i have done this:

Directory /var/www/python
  AddHandler python-program .py
  PythonHandler python
  Order allow,deny
  Allow from all
  #PythonDebug On
/Directory

 the script is in this directory /var/www/python

 but i get an 500 error everytime, with every script 

You're confusing mod_python and cgi. And you're cgi isn't written
properly...

Try this to enable cgi for python files:

Directory /var/www/python
Options +ExecCGI
AddHandler cgi-script py
/Directory

Don't forget to restart apache.

A proper cgi-file outputs a header with at least the content-type. A
header is followed by an empty line.

#!/usr/bin/env python

import os

print Content-type: text/html
print
print os.getcwd()

--
Peter van Kampen
pterk -- at -- datatailors.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache Python 500 Error

2005-02-03 Thread Jeremy Bowers
On Thu, 03 Feb 2005 13:55:13 +0100, Christian wrote:
 from mod_python import apache
 ^
 SyntaxError: invalid syntax
 
 
 My test script:
 #!/usr/bin/python
 
 print 'Content-Type: text/plain\r'
 print '\r'
 import os
 print os.getcwd()

For the quote of the error message, I've taken the liberty of stripping
off the apache-added stuff off the front so you can read it better.

You should now be able to easily see that the error message and your shown
program don't mesh. That error appears to be from an earlier run.

Even so, I can tell you one thing: The error resulted from indenting your
from mod_python import apache call that you no longer have. Python uses
whitespace for structure, and just as you must indent the body of loops,
you must *not* extraneously indent other things (line continuations
don't count).

You'll need to post the correct error message after configuring Apache for
CGI as Peter showed, unless of course you figure out the problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Apache Python 500 Error

2005-02-02 Thread Christian
Hello,
i have an apache 1.3 server with python on debian. Python works fine but 
 the scripts wont´t work.

This easy script i want to do on apache:
#!/usr/bin/python
import os
os.getcwd()
in apache config i have done this:
Directory /var/www/python
AddHandler python-program .py
PythonHandler python
Order allow,deny
Allow from all
#PythonDebug On
/Directory
the script is in this directory /var/www/python
but i get an 500 error everytime, with every script - why that - i´m 
newbie - sorry for that :)

greetings from germany to newsgroup
christian
--
http://mail.python.org/mailman/listinfo/python-list


Re: Apache Python 500 Error

2005-02-02 Thread Fuzzyman
What does the error log report ?

It is *possible*  that you are getting an error 500 because your are
not emitting valid headers.

Try this instead :

#!/usr/bin/python

print 'Content-Type: text/plain\r'
print '\r'
import os
print os.getcwd()
Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache Python 500 Error

2005-02-02 Thread Jeremy Bowers
On Wed, 02 Feb 2005 10:28:46 +0100, Christian wrote:

 Hello,
 
 i have an apache 1.3 server with python on debian. Python works fine but
   the scripts wontt work.

I know what your problem is.

But first, check your apache error log. Then you will know what your error
is, too.

If you can't fix it after you try to fix the error in the log, or you
don't understand the log entry, post your program and all relevant log
entries. You did good posting your Apache configuration, but we also need
the log entries.

That said, fuzzyman is right, but keep this in mind for future help
requests.
-- 
http://mail.python.org/mailman/listinfo/python-list