473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

apache 2 & python

how to configure apache 2 to work with python or mod_python?

krzysiek

ps: sory,my english is't perfect :)
Jul 18 '05 #1
3 2243
In data Thu, 19 Aug 2004 00:42:26 +0200, Krzysztof Drozd ha scritto:
how to configure apache 2 to work with python or mod_python?


Look at mod_python's howto guide:
http://modpython.org/live/current/do...tallation.html

--
Lawrence (l dot oluyede at virgilio dot it)
"If the implementation is hard to explain, it's a bad idea."
from The Zen of Python by Tim Peters
Jul 18 '05 #2
Am Thu, 19 Aug 2004 00:42:26 +0200 schrieb Krzysztof Drozd:
how to configure apache 2 to work with python or mod_python?


You can use SCGI:
http://www.mems-exchange.org/software/scgi/

The docs says it is not well tested for apache2,
but I had no problems, after I realized that
you need to set "SetHandler scgi-handler".

HTH,
Thomas
Jul 18 '05 #3
md
Krzysztof Drozd wrote:
how to configure apache 2 to work with python or mod_python?

krzysiek

ps: sory,my english is't perfect :)


I use Python for my Apache2 CGI scripts without mod_python (have not
tried it yet). Using the cgi module you can POST and GET quite easily
and it makes for very simple to write dynamic web pages.

First, you will need to add an item to httpd.conf. In httpd.conf add a
ScriptAlias for your script name(you should already have one for
/cgi-bin/ ):

....
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin"
ScriptAlias /nameScript/ "/usr/local/apache2/cgi-bin/nameScript.py"
....

Then write your script in that location. The script below would expect
an http POST or url value like this:

http://www.whatever.com/?nameScript&user_name=Foo

The script below ties it all in....

+------

#!/usr/bin/python
import cgitb; cgitb.enable() #provides HTML error support
import cgi

form = cgi.FieldStorage()

def CGI(content_type="text/html"):
return 'Content type: %s\n\n' % content_type

def form_val(key):
"""
Use this simple method to get http POST's
"""
val = form.getlist(key):
if (val == None): return None
return val

user_name = form_value('user_name')

def display_page(name):
print CGI()
print "<html><head><title>"\
"This is %s's page</title>"\
"</head><body><h1>Welcome, %s"\
"</h1><body></html>" %(name, name)
return 1 #

display_page(the_name)

----+

There are also other modules you can use to help produce your HTML with
out typing it out for yourself and thus making it all more Pythonesque.

Hope this wasn't over the top and that it helps.

Mark d.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rolfe | last post by:
Hi, I struggled, and got mod_python running on Apache/Win2k. Follow these instructions verbatim and you shouldn't have any trouble. These instructions are based on...
0
by: Greeshma | last post by:
Hi all, I have successfully configured Apache 2.0.4 with RedHat 7.3 and use Python 2.2.3 for cgi scripts. When I start Apache manually through /usr/local/apache/bin/apachectl startssl, I can...
1
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
2
by: Christian | last post by:
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()
1
by: neha | last post by:
hi, i m trying to integrate python with apache on linux.For this i m using mod_python. I dont see any problem with the versions of python,apache and mod_python i m using. the versions i m using...
1
by: Tama | last post by:
Hello, I've didn't find any answer to my problem so I start a new topic. I have installed Apache 1.3.33 on Windows XP. I've also downloaded and installed ActivePython form...
5
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major...
3
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory...
1
by: NccWarp9 | last post by:
Hello, im using Apache HTTPD 2.2.8 with mod_python/3.3.1 Python/2.4.3 on Windows and having truble starting pythone, any help would be appreciated .. Im getting this error: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.