1:引用sanic
pip install sanic
2: 引用sanic 跨域
3:
#-*- coding: UTF-8 -*-
# !/usr/bin/python
# @time :2022/2/22 21:43
# @author :Mo
# @function :get/post of sanicfrom sanic.response import json, text
from sanic import Sanic, request
from sanic_cors import CORSapp = Sanic("test")
app.config.HEALTH = True
CORS(app)#这是个测试
@app.route("/test/haha", methods=["GET"])
async def calculate_add(request):""" 分类 """params = request.argsprint(request)tt = params.get("tt", 0)print(tt)data_dict = {"c": tt}status_code = 200res_dict = {"code": status_code,"data": data_dict,"message": "success"}return json(res_dict, status=status_code, ensure_ascii=False)if __name__ == "__main__":app.run(single_process=True,access_log=True,host="0.0.0.0",port=1111,workers=1,)
4:查看