- Replace Next.js/React implementation with Python Flask - Add colorful blue-purple-teal gradient theme replacing red design - Integrate logo and Transalpina panoramic background image - Implement complete authentication system with Flask-Login - Add community features for stories and tracks sharing - Create responsive design with Tailwind CSS - Add error handling with custom 404/500 pages - Include Docker deployment configuration - Add favicon support and proper SEO structure - Update content for Pensiune BuonGusto accommodation - Remove deprecated Next.js files and dependencies Features: ✅ Landing page with hero section and featured content ✅ User registration and login system ✅ Community section for adventure sharing ✅ Admin panel for content management ✅ Responsive mobile-first design ✅ Docker containerization with PostgreSQL ✅ Email integration with Flask-Mail ✅ Form validation with WTForms ✅ SQLAlchemy database models ✅ Error pages and favicon handling
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_migrate import Migrate
|
|
from flask_login import LoginManager
|
|
from flask_mail import Mail
|
|
from config import config
|
|
import os
|
|
|
|
db = SQLAlchemy()
|
|
migrate = Migrate()
|
|
login_manager = LoginManager()
|
|
mail = Mail()
|
|
|
|
def create_app(config_name=None):
|
|
app = Flask(__name__)
|
|
|
|
config_name = config_name or os.environ.get('FLASK_CONFIG') or 'default'
|
|
app.config.from_object(config[config_name])
|
|
|
|
# Initialize extensions
|
|
db.init_app(app)
|
|
migrate.init_app(app, db)
|
|
login_manager.init_app(app)
|
|
mail.init_app(app)
|
|
|
|
# Configure login manager
|
|
login_manager.login_view = 'auth.login'
|
|
login_manager.login_message = 'Please log in to access this page.'
|
|
login_manager.login_message_category = 'info'
|
|
|
|
@login_manager.user_loader
|
|
def load_user(user_id):
|
|
from app.models import User
|
|
return User.query.get(int(user_id))
|
|
|
|
# Import models
|
|
from app.models import User, Post, PostImage, GPXFile, Comment, Like
|
|
|
|
# Register blueprints
|
|
from app.routes.main import main
|
|
app.register_blueprint(main)
|
|
|
|
from app.routes.auth import auth
|
|
app.register_blueprint(auth, url_prefix='/auth')
|
|
|
|
from app.routes.community import community
|
|
app.register_blueprint(community, url_prefix='/community')
|
|
|
|
# Create upload directories
|
|
upload_dir = os.path.join(app.instance_path, 'uploads')
|
|
os.makedirs(upload_dir, exist_ok=True)
|
|
os.makedirs(os.path.join(upload_dir, 'images'), exist_ok=True)
|
|
os.makedirs(os.path.join(upload_dir, 'gpx'), exist_ok=True)
|
|
|
|
return app
|
|
|
|
@login_manager.user_loader
|
|
def load_user(user_id):
|
|
from app.models import User
|
|
return User.query.get(int(user_id))
|