差不多一年来,我一直在同一个问题上蹒跚而行。我总是想办法解决它,但我厌倦了找工作。
我需要的是在Web页面上创建一个按钮(最好是HTML,而不是PHP或ASP),它在服务器上运行python脚本。我也希望这个按钮能够将信息从表单发送到脚本。
我需要在本地主机上,通过Amazon云上托管的web服务来完成这项工作。我将无法在Amazon云服务上安装任何额外的东西,比如PHP或CGI。
我真的很想要一个简单的解决方案,我是python的专家,我可以编写网页,但我只是找不到一个简单的解决方案来解决这个问题。
我的理想解决方案是像邮件标签:
<a href="mailto:someone@example.com?Subject=Hello%20again">Send Mail</a>
除外:
<a href="myscript.py?Subject=1234">Run Script</a>
现在我非常怀疑这样的解决方案是否存在,但我可以做正确的梦。
我要运行的脚本:
编辑--------
多亏了@Ketouem的回答,我才找到了解决问题的好办法。我将在这里发布一些代码,以便其他人受益。一定要下载python的瓶子模块,它很棒。
# 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)
你可以使用瓶子:http://bottlepy.org/docs/dev/index.html这是一个轻量级的web框架
相关问题 更多 >
编程相关推荐