【发布时间】:2013-08-09 12:34:33
【问题描述】:
我有一个 python 脚本,我希望用户在服务器中运行它,但不提供 SSH 登录权限。我从下面的链接获得了一个网络应用程序。 How to connect a webpage with python to mod_wsgi?
这是适合我的修改版本
import web
class Echo:
def GET(self):
return """<html><form name="script-input-form" action="/" method="post">
<p><label for="Import"><font color=green><b>Press the button to import CSV</b></font)</label>
Import: <input type="submit" value="ImportCSV"></p>
</form><html>"""
def POST(self):
data = web.input()
return data
obj = compile('execfile("importcsv.py")', '', 'exec')
result = eval(obj, globals(), locals())
web.seeother('/')
urls = (
'/.*', Echo,
)
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
else:
app = web.application(urls, globals()).wsgifunc()
我存储在 site.py 中的脚本,我正在使用命令“python2.7 site.py 10.10.10.19:8080”执行它。当用户访问 10.10.10.19:8080 时,他可以看到网页,并在希望执行代码时单击按钮。
现在问题是
当我关闭我的 SSH 会话时网页停止:(
我如何在后台运行它?试过 & 并没有帮助。
感谢和问候, 里吉尔·哈里
【问题讨论】:
-
服务器运行的是 Windows 还是 *nix?
-
不是 Windows,而是 Ubuntu 12.04
标签: python web-applications wsgi