45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""
|
|
Pets of Powerwashing - A Flask application for managing pet picture submissions
|
|
"""
|
|
|
|
from flask import Flask
|
|
import os
|
|
|
|
|
|
def create_app():
|
|
"""Application factory pattern for Flask app creation"""
|
|
app = Flask(__name__)
|
|
|
|
# Import configuration
|
|
from app.config import Config
|
|
app.config.from_object(Config)
|
|
|
|
# Ensure upload directory exists
|
|
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
|
|
|
# Setup logging
|
|
from app.utils.logging_config import setup_logging
|
|
setup_logging(app)
|
|
|
|
# Register error handlers
|
|
from app.utils.error_handlers import register_error_handlers
|
|
register_error_handlers(app)
|
|
|
|
# Initialize database
|
|
from app.models.database import init_db, close_db
|
|
with app.app_context():
|
|
init_db()
|
|
|
|
# Register database close function
|
|
app.teardown_appcontext(close_db)
|
|
|
|
# Register blueprints
|
|
from app.routes.main import main_bp
|
|
from app.routes.auth import auth_bp
|
|
from app.routes.pictures import pictures_bp
|
|
|
|
app.register_blueprint(main_bp)
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(pictures_bp)
|
|
|
|
return app |