Is there a way to separate route variable and route args in Flask

Viewed 31

Currently I have

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

While when the request url is '/api/job/456?id=123'

job_id becomes 456?id=123. Is there a way I can get the job_id as 456 and exclude the args part?

1 Answers

Use request.args to get parsed contents of query string:

from flask import request

@app.route(...)
def handle_request():
    id = request.args.get('id')
Related