目录结构
cms模块
from flask import Blueprintbp = Blueprint('cms', __name__, url_prefix='/cms')@bp.route('/')def index(): return 'cms index'
from .views import bp
common模块
from flask import Blueprintbp = Blueprint('common', __name__, url_prefix='/common')@bp.route('/')def index(): return 'common index'
from .views import bp
front模块
from flask import Blueprintbp = Blueprint('front', __name__)@bp.route('/')def index(): return 'front index'
from .views import bp
config
主文件
from flask import Flaskfrom apps.cms import bp as cms_bpfrom apps.common import bp as common_bpfrom apps.front import bp as front_bpimport configapp = Flask(__name__)app.config.from_object(config)app.register_blueprint(cms_bp)app.register_blueprint(common_bp)app.register_blueprint(front_bp)if __name__ == '__main__': app.run(host='0.0.0.0', port=8888)
运行