1. 安装包 pip install tornado
from tornado import web, ioloop
class MainHandler(web.RequestHandler):
def get(self):
self.write("我是GET请求")
def post(self):
self.write("我是POST请求")
def make_app():
return web.Application([
(r"/", MainHandler),
],debug=True) # 开启debug
if __name__ == "__main__":
app = make_app()
app.listen(8888) # 监听端口
ioloop.IOLoop.current().start() # 启动