Flask Framework Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

A simple GET request

The following is a simple example of what a GET request looks like.:

@app.route('/a-get-request') 
def get_request(): 
    bar = request.args.get('foo', 'bar') 
    return 'A simple Flask request where foo is %s' % bar 

Here, we just check whether the URL query has an argument called foo. If yes, we display this in the response; otherwise, the default is bar.