繁体   English   中英

“sanic”中的占位符 python

[英]Placeholder in “sanic” python

我最近一直在使用 python 中的 Sanic 模块,我想知道是否有办法在 url 中定义占位符。 这有点难以解释,但我会尽力而为。

我希望它是这样的。 Url: /account/api/public/account/PlaceholderHere/externalAuths谁能帮我解决这个问题?

您可以在路由装饰器中的占位符周围使用<>

my_route = Blueprint("my_route")

@my_route.route("/account/api/public/account/<placeholder>/externalAuths", methods=["GET"])
async def get_my_route(request, placeholder):
  print(f"here is my placeholder: {placeholder}")

阅读文档中的参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM