python tornado_and_flask.py
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python tornado_and_flask.py相关的知识,希望对你有一定的参考价值。
# tornado:
import datetime
from tornado.web import Application, RequestHandler, asynchronous
from tornado.ioloop import IOLoop
from tornado.options import parse_command_line
io_loop = IOLoop.instance()
delay = datetime.timedelta(milliseconds=3)
class Sleep(RequestHandler):
@asynchronous
def get(self):
io_loop.add_timeout(delay, lambda: self.finish("end"))
if __name__ == "__main__":
parse_command_line()
Application([(r"/", Sleep)]).listen(8000)
io_loop.start()
# flask:
import sys
import time
from urllib.parse import unquote
from urllib.request import urlopen
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
f = urlopen('http://localhost:8000/')
return f.read()
if __name__ == "__main__":
app.run(host="0.0.0.0", threaded=True, debug=True)
以上是关于python tornado_and_flask.py的主要内容,如果未能解决你的问题,请参考以下文章
001--python全栈--基础知识--python安装
Python代写,Python作业代写,代写Python,代做Python
Python开发
Python,python,python
Python 介绍
Python学习之认识python