473,800 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Quickest way to make py script Web accessible

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!

Jan 5 '06 #1
9 1373

rt*****@vt.edu wrote:
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/?

--
-Todd
http://www.signalsguru.net

Jan 5 '06 #2
Jim
rt*****@vt.edu wrote:
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

Jan 5 '06 #3
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

Jan 5 '06 #4

rt*****@vt.edu wrote:
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_c gi_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

Jan 5 '06 #5
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.

Jan 5 '06 #6
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_typ e = 'text/plain'
req.write("Hell o World!")
return apache.OK

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

Jan 5 '06 #7
Thank you all for the advice and suggestions. I appreciate the time you
took to help!

Jan 5 '06 #8

rt*****@vt.edu wrote:
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).

Jan 5 '06 #9
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

Jan 7 '06 #10

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

Similar topics

17
4890
by: Mike A | last post by:
Hi, I'm hoping someone can help me with this. I have a URL for which I'd like to limit access to by time. For example,say I have a URL that I don't want accessable on Monday mornings between 10am-noon and Fri. afternoons between 2-4pm. So when someone clicks on the URL during those times a message pops up saying somthing like "sorry we're closed now etc" Is this possible? if yes, I'm guessing I'll need somesort of "onclick" for the
6
4137
by: me | last post by:
Hi guys - the question is in the subject line. I thought of one quick way: std::ifstream input("myfile.dat") ; std::istreambuf_iterator beg(input), end ; std::vector DataFile(beg,end) ;
4
2077
by: Odin | last post by:
Hello I am making a webpage with two dropdown menus. First I have a dropdown menu with a list of 235 countries. When one country is selected from this list the contents of the next dropdown menu is decided from a coresponding file containing a huge amount of cities. The biggest of these files being 6 MB. Getting different advices I have now to different sets of code doing this thing. Does anyone know if any of these two sets of code is...
11
3103
by: comp.lang.php | last post by:
On one of my sites, I have a TCL CGI script that has a security hole in spite of it having effective server-side validation (the fact that it's CGI IS its security hole). The front end is a PHP script, and I am writing server-side validation onto it, however, it is required to redirect to the TCL CGI script because only a CGI script has the ability to access a group-accessible XML script on the back end. I had to take the whole thing...
2
1413
by: Emmanuel | last post by:
Hi there, My client would like to process an xml file. the structure of which is as below. <xml> <stockitem> <releaseddate>.....date value...</releaseddate> <...aditional tags for additional info> </stockitem> <stockitem>
1
5637
by: prash.marne | last post by:
Hi, I am trying open a simple popup window & my code is .. <html> <head> <title>popup_window</title> <script type="text/javascript"> function popup_onclick(){ my_window = window.open("",'windowname','width=400,height=200');
2
1844
by: Andrey Fedorov | last post by:
Is the scope of a closure accessible after it's been created? Is it safe against XSS to use closures to store "private" auth tokens? In particular, in... ....can untrusted code access 'secret', or only the code inside foo? - Andrey
1
47492
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9551
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
10505
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...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
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
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5471
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
4149
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
3
2945
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.