<分区>
我安装了 Tornado 2.4,如何运行应用程序?我需要安装 ngnix 吗?在文档中不要写关于正在运行的应用程序!
我用的是 ubuntu,谢谢!
<分区>
我安装了 Tornado 2.4,如何运行应用程序?我需要安装 ngnix 吗?在文档中不要写关于正在运行的应用程序!
我用的是 ubuntu,谢谢!
最佳答案
创建一个 python 文件 server.py
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8888, help="run on the given port", type=int)
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
def main():
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()
现在您可以使用 python 启动它了!
python server.py
打开浏览器 --> http://127.0.0.1:8888
关于python - 从 Tornado 开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13331580/