How do I run a python program from an internet address?
alex23
wuwei23 at gmail.com
Tue May 8 20:42:40 EDT 2012
On May 8, 9:20 am, Albert <albertsu... at gmail.com> wrote:
> I have a small text based python program that I want to make available
> to people who might be behind a firewall or can't install python on
> their office computers, but can access the internet. It is just an
> algorithm that makes a handful of straightforward calculations on some
> input that the user provides and spits out some text as output that
> they might want to print out on a printer. I can program python on my
> local machine, but don't know how to make the code accessible from a
> browser.
You could do this quite easily with CherryPy:
import cherrypy
class WebApp(object):
def calc(self, a, b):
c = int(a) + int(b)
return str(c)
calc.exposed = True
cherrypy.quickstart(WebApp())
This can be called via '/calc/1/2' or 'calc?a=1&b=2'. You can add a
method to provide a form and another to produce a pretty output and
it's good to go.
http://www.cherrypy.org/
More information about the Python-list
mailing list