Reputation: 1443
I've been stumbling along with the same problem for almost a year now. I always find a way to work around it, but I'm tired of finding work arounds.
What I need is to create a button on a Web Page (preferable HTML, not PHP or ASP) that runs a python script on the server. I'd also like the ability to have this button send information from a form to the script.
I need to do this on a local host and through a web service hosted on the Amazon Cloud. I won't be able to install anything extra on the Amazon Cloud service, such as PHP or CGI.
I'd really like an easy solution, I'm an expert with python and I can write webpages that whistle, but I just can't find a simple solution to this problem.
My ideal solution would be something like the mail to tag:
<a href="mailto:[email protected]?Subject=Hello%20again">Send Mail</a>
Except:
<a href="myscript.py?Subject=1234">Run Script</a>
Now I highly doubt a solution like that exists, but well I can dream right.
The script I am trying to run:
EDIT ---------------------------
Thanks to @Ketouem answer I was able to find a great solution to my issue. I'll post some of the code here so that others can benefit. Make sure you download the Bottle Module for python, its great.
# 01 - Import System Modules
from bottle import get, post, request, Bottle, run, template
# 02 - Script Variables
app = Bottle()
# 03 - Build Temporary Webpage
@app.route('/SLR')
def login_form():
return '''<form method="POST" action="/SLR">
Parcel Fabric ID: <input name="UID" type="text" /><br />
Save Location: <input name="SaveLocation" type="text" value="D:/Python27/BottleTest/SLR_TestOutputs"/><br />
Air Photo On: <input name="AirPhoto" type="checkbox"/><br />
Open on Completion: <input name="Open" type="checkbox"/><br />
Scale: <input name="Scale" type="text" value="10000"/><br />
<input type="submit" />
</form>'''
# 04 - Return to GIS App
@app.route('/SLR', method='POST')
def PHPH_SLR_Script():
# I won't bother adding the GIS Section of the code, but at this point it send the variables to a program that makes a map. This map then saves as an XML and opens up in a new tab.
# 04 - Create and Run Page
run(app, host='localhost', port=8080)
Upvotes: 10
Views: 19310
Reputation: 3857
You could use Bottle : http://bottlepy.org/docs/dev/index.html which is a light web framework
Upvotes: 8