【问题标题】:Placeholder in "sanic" python“sanic”python中的占位符
【发布时间】:2021-01-17 03:32:00
【问题描述】:

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

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

【问题讨论】:

标签: python sanic


【解决方案1】:

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

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}")

在文档中了解parameters

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-24
    • 2019-06-04
    • 2014-10-07
    • 1970-01-01
    • 2013-09-13
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多