标签:class color 方便 dir reg views 相关 目录 blueprint
flask-蓝图(Blueprint)
from flask import Flask from user.views import user_app import sys import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(BASE_DIR, ‘apps‘)) apps = [ user_app, ] app = Flask(__name__) for each in apps: app.register_blueprint(each) if __name__ == ‘__main__‘: app.run()
1 from flask import Blueprint 2 3 user_app = Blueprint(‘user‘, __name__) 4 5 6 @user_app.route(‘/user/login‘) 7 def login(): 8 return ‘login page‘
每个蓝图就是一个额外的app,蓝图需要在app.register_blueprint里面进行注册
标签:class color 方便 dir reg views 相关 目录 blueprint
原文地址:https://www.cnblogs.com/ivy-blogs/p/11538031.html