Tutorial by Examples

Routes in Flask can be defined using the route decorator of the Flask application instance: app = Flask(__name__) @app.route('/') def index(): return 'Hello Flask' The route decorator takes a string which is the URL to match. When a request for a URL that matches this string is receive...
It may be useful to have one catch-all view where you handle complex logic yourself based on the path. This example uses two rules: The first rule specifically catches / and the second rule catches arbitrary paths with the built-in path converter. The path converter matches any string (including sl...
By default, routes only respond to GET requests. You can change this behavior by supplying the methods argument to the route() decorator. from flask import request @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': do_the_login() else: ...

Page 1 of 1