首先
安装tornado框架
pip install tornado==6.0.4
完成代码解析+注释
创建tornado🈳️项目
"""
导入模块
tornado.web 负责应用程序的开发
tornado.ioloop 负责服务启动
app = tornado.web.Application(
[ 为了防止转译,用r'' 阔上
(元组放在这里,后面写的是类试图函数)
]
)
"""
import tornado.web
import tornado.ioloop
# 创建视图类
class IndexHandler(tornado.web.RE):
# 遇到get请求,执行对应的get方法
def get(self):
self.write('龙卷风🌪️')
if __name__ == '__main__':
app = tornado.web.Application(
# 创建路由
[
(r'/index/', IndexHandler)
]
)
# 设置端口号
app.listen(8848)
# 启动
tornado.ioloop.IOLoop.current().start()
👌了 访问去吧 127.0.0.0.1:8848