""" 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 upload_path = os.path.join(app.static_folder, 'uploads') os.makedirs(upload_path, exist_ok=True) # Update config to use absolute path for file operations app.config['UPLOAD_FOLDER'] = upload_path # 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