- Fix upload folder path to be relative to Flask app static folder - Update app initialization to use proper static folder structure - Change default development port to 5001 to avoid AirPlay conflicts - Images now display correctly in both public and admin views The refactored app now properly serves uploaded images from the correct static file location. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.3 KiB
Python
48 lines
1.3 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
|
|
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 |