How do I run a python program from an internet address?

A

Albert

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.

What would be the best way to figure out how to do this? I looked at
Google app engine tutorial, but can't figure out how that will help we
get the code into the cloud so I can access it from any browser.
 
S

Steven D'Aprano

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.

What would be the best way to figure out how to do this?

Try googling "python web app how to". For example, the very first link
found here:

https://duckduckgo.com/html/?q=python web app how to

is an introduction to making Python applications available to run over
the Internet.
 
A

alex23

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/
 
P

Paul Rubin

Albert said:
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.

What kind of people? I.e. is it something you're doing for work, where
the users are (say) your co-workers?

If you're just asking the simplest way to put a python script on a web
page, I'd say it's to write a cgi and put it behind a normal web server.

I'd avoid stuff like Google app server if possible, especially if there
are any privacy concerns about the data going into the program. I much
prefer to use cheap virtual servers even though I have to pay for them.
They are amazingly affordable: you can get a 128MB server with enough
resources for typical personal websites for a couple USD a month. That
approach does require you to know a little bit about server
administration but it's not that big a deal.
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top