26 lines
674 B
Python
26 lines
674 B
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from config import Config
|
|
import os
|
|
|
|
db = SQLAlchemy()
|
|
|
|
def create_app(config_class=Config):
|
|
app = Flask(__name__)
|
|
app.config.from_object(config_class)
|
|
|
|
# Ensure upload directories exist
|
|
os.makedirs(app.config["PHOTO_FOLDER"], exist_ok=True)
|
|
os.makedirs(app.config["QR_FOLDER"], exist_ok=True)
|
|
os.makedirs(os.path.dirname(app.config["SQLALCHEMY_DATABASE_URI"].replace("sqlite:///", "")), exist_ok=True)
|
|
|
|
db.init_app(app)
|
|
|
|
from app.routes import main_bp
|
|
app.register_blueprint(main_bp)
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
return app
|