Python Flask routing configuration

For more Python development content, visit: "Python Flask Development Guide"

FlaskThe routing access function is implemented by using routedecorators, and its routing matching URLrules are based on Werkzeugthe routing module. This module builds on Apacheand earlier HTTPserver claims, hoping to be elegant and unique URL. Its usage format is as follows:

from flask import Flask
app = Flask(__name__)

@app.route('/hello')
def hello():
    return 'Hello, World'


if __name__ == '__main__':
    app.run(port=8080)

As above, it can be accessed via: http://127.0.0.1:8080/hello.

URL rules

routeThe decorator is implemented Werkzeugbased on rules  , we can mark part of the URL <variable_name> as

Guess you like

Origin blog.csdn.net/chf1142152101/article/details/128306733