Flask Accessing query string


Example

The query string is the part of a request following the URL, preceded by a ? mark.

Example: https://encrypted.google.com/search?hl=en&q=stack%20overflow

For this example, we are making a simple echo webserver that echos back everything submitted to it via the echo field in GET requests.

Example: localhost:5000/echo?echo=echo+this+back+to+me

Flask Example:

from flask import Flask, request

app = Flask(import_name=__name__)

@app.route("/echo")
def echo():

    to_echo = request.args.get("echo", "")
    response = "{}".format(to_echo)

    return response

if __name__ == "__main__":
    app.run()