Newbie: Where to start with cgi?
root
husam at sci.kun.nl
Wed Jun 18 13:02:24 EDT 2003
> Take a look at mod_python.
Thanks for the replies,
I went through webware and mod_python and I think they are indeed the
stuf that I need. But which one should I choose? I really don't know.
Any way, I started with mod_python this morning and the test scripts
worked find by displaying "hello world". But, when I followed the
tutorials on modpython.org I got stuck at a nother test script provided
by the tutrial. After 4 hours of trying still no go because the test
scripts are either don't work, or misunderstood by me.
These are the configurations:
/etc/httpd/conf/httpd.conf:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Directory /var/www/html>
AddHandler python-program .py
PythonAuthenHandler form
PythonHandler form
PythonDebug On
AuthType Basic
AuthName "Restricted Area"
require valid-user
</Directory>
/var/www/html/form.py:
~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/python
from mod_python import apache
def handler(req):
req.content_type = "text/html"
req.send_http_header()
req.write("Welcome ")
return apache.OK
def authenhandler(req):
user = req.user
pw = req.get_basic_auth_pw()
if user == "newbie" and pw == "python":
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
/var/www/html/form1.html:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<title>Form1</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
</head>
<body>
Name:<input type="submit" name="Login">
<br>
<br>
<br>
</body>
</html>
When form1.html is called the server generates this error:
Server error!
The server encountered an internal error and was unable to complete your
request. Either the server is overloaded or there was an error in a CGI
script.
If you think this is a server error, please contact the webmaster
Error 500
localhost
Wed 18 Jun 2003 06:58:07 PM CEST
Apache/2.0.40 (Red Hat Linux)
More information about the Python-list
mailing list