46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from flask import Flask
|
|
from config.database import init_db
|
|
from app.utils.email_service import mail
|
|
from config.config import Config
|
|
|
|
def create_app(config_name=None):
|
|
app = Flask(__name__)
|
|
app.config.from_object(Config)
|
|
|
|
# 初始化数据库
|
|
init_db(app)
|
|
|
|
# 初始化邮件服务
|
|
mail.init_app(app)
|
|
|
|
# 注册蓝图
|
|
from app.views.auth import auth_bp
|
|
from app.views.main import main_bp
|
|
from app.views.user import user_bp
|
|
from app.views.product import product_bp
|
|
from app.views.cart import cart_bp
|
|
from app.views.order import order_bp
|
|
from app.views.payment import payment_bp
|
|
from app.views.admin import admin_bp
|
|
from app.views.address import address_bp
|
|
from app.views.upload import upload_bp
|
|
from app.views.review import review_bp
|
|
from app.views.favorite import favorite_bp
|
|
from app.views.history import history_bp
|
|
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(main_bp)
|
|
app.register_blueprint(user_bp)
|
|
app.register_blueprint(product_bp)
|
|
app.register_blueprint(cart_bp)
|
|
app.register_blueprint(order_bp)
|
|
app.register_blueprint(payment_bp)
|
|
app.register_blueprint(admin_bp)
|
|
app.register_blueprint(address_bp)
|
|
app.register_blueprint(upload_bp)
|
|
app.register_blueprint(review_bp)
|
|
app.register_blueprint(favorite_bp)
|
|
app.register_blueprint(history_bp)
|
|
|
|
return app
|