有没有办法在Flask中分离路由变量和路由参数

时间:2020-06-25 01:36:46

标签: python flask

我现在有

@app.route("/api/job/<job_id>")
def handle_request(job_id):
  print(job_id)

当请求网址为'/ api / job / 456?id = 123'

job_id变为456?id = 123。 有没有办法我可以将job_id设为456,并排除args部分?

1 个答案:

答案 0 :(得分:0)

使用request.args来解析查询字符串的内容:

from flask import request

@app.route(...)
def handle_request():
    id = request.args.get('id')
相关问题