flask routing plan (blueprint)

# Unified routing Bluetooth planning 
# File: blueprint_route.py 
from the Flask Import the Blueprint 

route_test = the Blueprint ( " Home " , __name__ ) 

# routing only through the app registered after the entry into force 


"" " 
: the advantages of a unified route planning 
unified prefix 
later when the complex structure of the site maintainable 
"" " 
@ route_test.route ( " / " )
 DEF Home ():
     return  " address: / Home_Page " 
@ route_test.route ( " / API " )
 DEF API ():
     return  " address:home_page/api"
# File: register_test.py 

from the Flask Import Flask
 from blueprint_route Import route_test                   # import Bluetooth 
App = Flask ( __name__ )                                    # instance Flask application 
app.register_blueprint (route_test, url_prefix = " / Home " )        # Bluetooth unified registration routing prefix Home 
IF  __name__ == " __main__ " : 
    app.run (Host = " 0.0.0.0 " , Debug = Ture)                   # project entrance

 

Guess you like

Origin www.cnblogs.com/jum-bolg/p/10994188.html