473,781 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2260
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.FieldStorag e()

def CGI(content_typ e="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(ke y):
if (val == None): return None
return val

user_name = form_value('use r_name')

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

display_page(th e_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
2870
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 "http://www.modpython.org/live/current/doc-html/inst-testing.html". I've added specific information such as Windows filepaths and filenames so there's no ambiguity on what you should do. I encourage you to copy and paste to avoid typing errors. Cheers, Rolfe
0
1485
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 execute the cgi scripts without any problem from the browser. This works fine. When I put the Apache start line in /etc/rc.local file so that Apache starts automatically at boot time, Apache starts without any problem, and I can access the...
1
47613
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 java1.4.2_04 (JIT: null) My Java version is:
2
2296
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
2791
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 are apache version2. mod_python v3.1.14 python2.4 The problem is,when i m running my python script,after starting apache
1
3331
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 http://www.activestate.com/. Then I went to http://www.modpython.org/ and search how to use python script with my web pages. I've tried all the version of mod_python under 2.7.11. As I'm under Windows XP, I can only install
5
3118
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 issue ? thanks for any help.
3
4940
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 "D:/softwares/Apache2.2/htdocs"> AddHandler mod_python .py PythonHandler mptest PythonDebug On </Directory>
1
4288
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: make_obcallback: could not import mod_python.apache.\n
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.