其他分享
首页 > 其他分享> > sanic 路由

sanic 路由

作者:互联网

from sanic import Sanic
from sanic.response import json,file

app=Sanic("app")

# @app.route('/',methods=['POST'])
async def test(request):
    name=request.form.get("name")
    return json({'name':name})

# 路由,@app.route装饰器,其实就是app.add_route方法
app.add_route(test,'/',methods=['POST'])

# websocket协议理由
# @app.websocket()
# app.add_websocket_route()
if __name__ == '__main__':
    app.run(host="0.0.0.0",port=8000,debug=True)

 

标签:__,websocket,name,route,add,sanic,app,路由
来源: https://www.cnblogs.com/HHMLXL/p/14888333.html