1 Star 0 Fork 0

大数据--数据可视化/残疾人核验

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
router.py 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
workpc 提交于 2023-10-30 09:18 . 修改bug 尝试websocket
from sanic import Sanic
from sanic.response import json,text
app = Sanic.get_app("myapp")
# @app.get("/")
@app.route('/test', methods=["POST", "PUT"])
async def hello_world(request):
return text("Hello, world.")
#route
@app.route("/handtest")
async def handler(request):
#9种返回类型
return json({"foo": "bar"})
# app.add_route(handler, "/test")
@app.route("/path/to/<foo:str>")
async def handler(request, foo: str):
...
# @app.route("/path/to/<foo:ymd>")
# async def handler(request, foo: datetime.date):
# ...
# /path/to/2021-03-28
# 基于处理程序方法名生成 url 的方法:app.url_for()
'''
@app.route('/')
async def index(request):
# generate a URL for the endpoint `post_handler`
url = app.url_for('post_handler', post_id=5)
# Redirect to `/posts/5`
return redirect(url)
@app.route('/posts/<post_id>')
async def post_handler(request, post_id):
...
'''
#特殊
'''
>> > app.url_for("post_handler", post_id=5, arg_one="one", _anchor="anchor")
'/posts/5?arg_one=one#anchor'
# _external requires you to pass an argument _server or set SERVER_NAME in app.config if not url will be same as no _external
>> > app.url_for("post_handler", post_id=5, arg_one="one", _external=True)
'//server/posts/5?arg_one=one'
# when specifying _scheme, _external must be True
>> > app.url_for("post_handler", post_id=5, arg_one="one", _scheme="http", _external=True)
'http://server/posts/5?arg_one=one'
# you can pass all special arguments at once
>> > app.url_for("post_handler", post_id=5, arg_one=["one", "two"], arg_two=2, _anchor="anchor", _scheme="http",
_external=True, _server="another_server:8888")
'http://another_server:8888/posts/5?arg_one=one&arg_one=two&arg_two=2#anchor'
'''
#静态文件
'''
app.static("/", "/path/to/index.html")
'''
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/big-data----dataView/disability-verification.git
[email protected]:big-data----dataView/disability-verification.git
big-data----dataView
disability-verification
残疾人核验
master

搜索帮助