python - Tornado只能在127.0.0.1监听吗?
PHP中文网
PHP中文网 2017-04-17 17:22:09
0
4
931

刚刚开始学习Tornado,只在文档里看到可以设置端口,没看到设置IP的内容,难道必须要用Nginx转发???

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
巴扎黑

For reference only, it can be bound to 0.0.0.0, and then it can be accessed from the external network. The IP is the host address

def main():
    parse_options()
    http_server = tornado.httpserver.HTTPServer(Application(),xheaders=True)
    print "Server started on port "+str(options.port)
    http_server.bind(int(options.port), "0.0.0.0")# listen local only "127.0.0.1"
    http_server.start(1)
    tornado.ioloop.IOLoop.instance().start()


if __name__ == '__main__':
    main()
Peter_Zhu

Listen to 0.0.0.0

小葫芦

Listening 0.0.0.0

阿神

Application’s listen method can specify IP, such as

app.listen(8888, address="0.0.0.0")
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template