使用Flas定义自定义URL

2024-04-19 09:02:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用以下格式定义URL:

/config?customer=...&integration_type=...

其中customer和integration类型是变量。你知道吗

到目前为止,如文件所述。用户可以将其URL定义为:

@app.route("/do_thing/<some_variable>")
def hello(some_variable):
   return "Hello World!"

URL的格式为

/do_thing/variable

但那不是我想要的。如何定义我提到的格式?你知道吗


Tags: 文件用户configappurl类型定义格式
1条回答
网友
1楼 · 发布于 2024-04-19 09:02:29

所需的格式中包含查询字符串。我们不以格式定义查询字符串。你可以直接通过这个函数得到参数值。你知道吗

user = request.args.get('user')
@app.route("/do_thing")
def hello():
integration_type = request.args.get('integration_type')
customer = request.args.get('customer')
   return "Hello World!"

相关问题 更多 >