fix: resolve image display issues after refactor
- 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>
This commit is contained in:
@@ -15,7 +15,10 @@ def create_app():
|
|||||||
app.config.from_object(Config)
|
app.config.from_object(Config)
|
||||||
|
|
||||||
# Ensure upload directory exists
|
# Ensure upload directory exists
|
||||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
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
|
# Setup logging
|
||||||
from app.utils.logging_config import setup_logging
|
from app.utils.logging_config import setup_logging
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Config:
|
|||||||
SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)
|
SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)
|
||||||
|
|
||||||
# Upload settings
|
# Upload settings
|
||||||
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER') or 'app/static/uploads'
|
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER') or 'static/uploads'
|
||||||
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
|
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
|
||||||
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
|
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
|
||||||
|
|
||||||
|
|||||||
3
main.py
3
main.py
@@ -15,4 +15,5 @@ app = create_app()
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Development server configuration
|
# Development server configuration
|
||||||
debug_mode = os.environ.get('FLASK_ENV') == 'development'
|
debug_mode = os.environ.get('FLASK_ENV') == 'development'
|
||||||
app.run(debug=debug_mode, host='0.0.0.0', port=5000)
|
port = int(os.environ.get('PORT', 5001)) # Use port 5001 to avoid AirPlay conflict
|
||||||
|
app.run(debug=debug_mode, host='0.0.0.0', port=port)
|
||||||
|
|||||||
Reference in New Issue
Block a user