3

I have a route that echoes whatever is passed to a url parameter. If I pass something that contains a question mark, such as /question/What is faster than a speeding bullet? in a browser, the echoed value does not contain the question mark or anything after it. Flask is truncating the value because it expects query parameters to follow the question mark. How can I capture a url value that includes a question mark?

@app.route('/question/<value>')
def read_question(value):
    return value
davidism
  • 121,510
  • 29
  • 395
  • 339

1 Answers1

0

Two options that I can see:

  • ignore non-alphanumeric text, compressing them into - (see: Stack Overflow question URLS)
  • percent-encode the question mark as %3F. This is probably horrible and fraught with potential errors.
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290