For more Python development content, visit: "Python Flask Development Guide"
Flask
The routing access function is implemented by using route
decorators, and its routing matching URL
rules are based on Werkzeug
the routing module. This module builds on Apache
and earlier HTTP
server 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
route
The decorator is implemented Werkzeug
based on rules , we can mark part of the URL <variable_name>
as