剛剛開始學(xué)習(xí)Tornado,只在文檔里看到可以設(shè)置端口,沒看到設(shè)置IP的內(nèi)容,難道必須要用Nginx轉(zhuǎn)發(fā)???
2 回答

侃侃爾雅
TA貢獻(xiàn)1801條經(jīng)驗 獲得超16個贊
Application的listen方法可以指定ip,比如
app.listen(8888, address="0.0.0.0")

慕工程0101907
TA貢獻(xiàn)1887條經(jīng)驗 獲得超5個贊
僅供參考,可以綁定到0.0.0.0,就可以從外網(wǎng)訪問了,IP就是主機(jī)地址
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()
- 2 回答
- 0 關(guān)注
- 16585 瀏覽
添加回答
舉報
0/150
提交
取消