简体   繁体   中英

Placeholder in “sanic” python

I've recently been working with the Sanic module in python and I was wondering If there's a way to define placeholders in a url. This is kind of hard to explain but I'm going to try my best.

I want it to be like this kind of. Url: /account/api/public/account/PlaceholderHere/externalAuths Can anyone help me with this?

You can use <> around the placeholder in your route decorator:

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

Read about parameters in the docs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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