# -*- coding: utf-8 -*- # import fcrm from fcrm import app if __name__ == '__main__': # fcrm.app.run(port=8081) app.run(port=8081)
启动启动文件,然后自动执行fcrm包下的init方法
from flask import Flask from .views.account import account from .views.order import order app = Flask(__name__,) app.register_blueprint(account) app.register_blueprint(order)
# -*- coding: utf-8 -*- from flask import Blueprint,render_template account = Blueprint("account",__name__) # 函数名和@account的名字重复会报错,应当避免 @account.route("/login") def login(): return render_template("login.html")
启动启动文件→加载fcrm包下边的init文件→自动导入执行视图函数;
这么做,你的业务逻辑就可以分开,,避免代码太多太杂