Crossin的编程教室
标题:
【答案】web.py, app.run()如何更换端口
[打印本页]
作者:
jxgx072037
时间:
2018-11-6 18:45
标题:
【答案】web.py, app.run()如何更换端口
本帖最后由 jxgx072037 于 2018-11-6 18:47 编辑
命令行里是很方便的,python xxx.py 8888就可以了
但是如果直接在代码里更改启动端口的话,找了很久的解决方法。终于找到了,在此备注一下:
https://stackoverflow.com/questi ... fy-address-and-port
import web
class MyApplication(web.application):
def run(self, port=8080, *middleware):
func = self.wsgifunc(*middleware)
return web.httpserver.runsimple(func, ('0.0.0.0', port))
if __name__ == "__main__":
app = MyApplication(urls, globals())
app.run(port=8888)
欢迎光临 Crossin的编程教室 (https://bbs.crossincode.com/)
Powered by Discuz! X2.5