可以实现远程脚本更新等功能
[Python] 纯文本查看 复制代码 #!/usr/bin/python
# -*- coding: UTF-8 -*-
import os,sys
from wsgiref.simple_server import make_server
from getVersion import getGameVersion
reload(sys)
sys.setdefaultencoding('utf8')
def application(environ, start_response):
if (environ['PATH_INFO'][1:])=="updata":
start_response('200 OK', [('Content-Type', 'text/html;charset=utf-8')])
return '<h1>更新成功!</h1>'
elif (environ['PATH_INFO'][1:])=="getVersion":
channel = environ['QUERY_STRING'].split('=')[1]
ret = getGameVersion(channel)
start_response('200 OK', [('Content-Type', 'text/html;charset=utf-8')])
text = ""
for game,info in ret.items():
text = text + '<tr>'
text = text + '<td>' +str(info['name'])+ '</td>'
text = text + '<td>' +str(game)+ '</td>'
text = text + '<td>' +str(info['ver'])+ '</td>'
text = text + '</tr>'
return '<table><thead><tr><th> 游戏名称 </th><th> 游戏ID </th><th> 版本信息 </th></tr></thead><tbody>'+ text+ '</tbody></table>'
else:
start_response('200 ok', [('Content-Type', 'text/html',)])
return '<h1> url error</h1>'
httpd = make_server('', 8000, application)
print "Serving HTTP on port 8000..."
httpd.serve_forever() |