Quickest way to make py script Web accessible

R

rtilley

What is the quickiest and easiest way to make a py script run on a Web
server? I have access to an Apache Web server running on Linux.

I'm often asked to run some of my scripts on behalf of others. My hope
is to make a simple Web-based interface where people could run the
scripts themselves whenever they like... instead of asking me.

I'd rather not rewrite the scripts with PHP. Any tips on a fast, easy
way of doing this?

Thanks!
 
T

Todd

What is the quickiest and easiest way to make a py script run on a Web
server? I have access to an Apache Web server running on Linux.

I'm often asked to run some of my scripts on behalf of others. My hope
is to make a simple Web-based interface where people could run the
scripts themselves whenever they like... instead of asking me.

I'd rather not rewrite the scripts with PHP. Any tips on a fast, easy
way of doing this?

Thanks!

I haven't tried it myself, but have you looked into
http://www.modpython.org/?
 
J

Jim

What is the quickiest and easiest way to make a py script run on a Web
server? I have access to an Apache Web server running on Linux.

I'm often asked to run some of my scripts on behalf of others. My hope
is to make a simple Web-based interface where people could run the
scripts themselves whenever they like... instead of asking me.
Perhaps I'm not understanding the question, but ..

Can you write a CGI script that calls the desired program using
Python's system call, like:
os.system("/home/rtilley/cleanup.py")
and then returns a little HTML saying that the cleanup was done at
such-and-such a time?

Is that what you are asking to do?
Jim
 
?

=?iso-8859-1?q?Luis_M._Gonz=E1lez?=

Karrigell lets you run pure python scripts, although not directly in
Apache.
It uses its own server running behind apache.

You can code in 4 styles:

-pure python scripts
-python in html (like in PHP)
-html in python
-karrigell services (mapping functions to urls)

http://karrigell.sf.net

Hope this helps...
Luis
 
J

jmdeschamps

What is the quickiest and easiest way to make a py script run on a Web
server? I have access to an Apache Web server running on Linux.

I'm often asked to run some of my scripts on behalf of others. My hope
is to make a simple Web-based interface where people could run the
scripts themselves whenever they like... instead of asking me.

I'd rather not rewrite the scripts with PHP. Any tips on a fast, easy
way of doing this?

Thanks!

If it's just using the web to *run* a python script on the server, then
a simple cgi-script which will spawn a process for other scripts.

You need a web form that permit the user to choose the script he/she
wants executed.

That form will point (action='your_cgi_script.py') to the script who's
job will be to spawn the other script, submitting the user choice.

One HTML page for the script choices and one extra python script to
receive the cgi call, seems easy!

If it doesn't look that way to you, don't hesitate to let it be known,
and on which part...

Jean-Marc
 
R

rtilley

I apologize for my inital ambiguity.

Say I have a .py script that gets email addresses from a database and
then sends messages to customers (this is not spam, these guys _want_
to get the emails). Historically, IT has executed the script when
someone in Marketing makes a request. I want to make it so that
Marketing can run the script themselves by executing the script through
a Web-based interface. I don't want to have to alter the script a great
deal in order to do this.
 
R

rtilley

This works well! Thanks for the advice. The docs for it should include
something about adding content_type = 'text\plain' otherwise, the
'testing' section of the tutorial is broken

It should look like this:
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK

Not this:
from mod_python import apache
def handler(req):
req.write("Hello World!")
return apache.OK
 
R

rtilley

Thank you all for the advice and suggestions. I appreciate the time you
took to help!
 
J

jmdeschamps

I apologize for my inital ambiguity.

Say I have a .py script that gets email addresses from a database and
then sends messages to customers (this is not spam, these guys _want_
to get the emails). Historically, IT has executed the script when
someone in Marketing makes a request. I want to make it so that
Marketing can run the script themselves by executing the script through
a Web-based interface. I don't want to have to alter the script a great
deal in order to do this.

I think my previous suggestion was just on the nose - none of your
scripts need be modified EXCEPT if they entail user input, for which
you would have to a web form to get such info from your user. and have
your cgi call your mail program with the parameters submitted from the
web form (such group of customers, such message, etc).

An alternative to spawning a process, is importing the mail script
within the cgi script itself (conditionnaly if need be).
 
F

Fuzzyman

Turning a script into a CGI is a brain-dead easy way of web-enabling a
script.

You could even make the script dual purpose by checking for the
existence of CGI environment variables. If they exist the script is
running as a CGI.

There are lots of resources on the internet on how to write CGIs.

All the best,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top