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)