目录结构
test
app
user.py
run.py
user.py
1 #!/usr/bin/env python 2 #-*- coding: utf-8 -*- 3 4 from flask import Blueprint 5 6 user = Blueprint('user',__name__) 7 8 @user.route('/loging/') 9 def login(): 10 return '欢迎登陆' 11 12 @user.route('/register/') 13 def register(): 14 return '欢迎注册'
run.py
1 #!/usr/bin/env python 2 #-*- coding: utf-8 -*- 3 4 5 from flask import Flask 6 7 app = Flask(__name__) 8 9 @app.route('/') 10 def index(): 11 return 'hello FLask' 12 from app.user import user 13 app.register_blueprint(user, url_prefix='/user') 14 15 if __name__ == '__main__': 16 app.run()
访问
访问蓝图注册的路由