最近不知道为什么开始搞模型工程化了
以前都是用Flask写的非常糙
最近公司用Sanic部署,所以研究了一下
首先是主函数 main.py
from sanic import Sanic
from sanic.response import json
app = Sanic('App Name')
@app.route("/")
async def test(request):
return json({"hello": "world"})
if __name__ == "__main__":
app.run(host="127.0.0.1", port=9000) #文档里面给的是0.0.0.0 但是执行不成功,不知道为什么
在shell中cd到这个文件的地址并用python执行启动服务
C:\Users\yihao tu\Desktop\sanic_test>python main.py
[2021-07-14 17:50:08 +0800] [20100] [INFO] Goin' Fast @ http://127.0.0.1:9000
[2021-07-14 17:50:08 +0800] [20100] [INFO] Starting worker [20100]
[2021-07-14 17:50:20 +0800] - (sanic.access)[INFO][127.0.0.1:6168]: GET http://127.0.0.1:9000/ 200 17
[2021-07-14 17:50:20 +0800] - (sanic.access)[INFO][127.0.0.1:6168]: GET http://127.0.0.1:9000/favi