Files
moto-adv-website/app/__init__.py
ske087 6a0548b880 Final cleanup: Complete Flask motorcycle adventure app
- Removed all Node.js/Next.js dependencies and files
- Cleaned up project structure to contain only Flask application
- Updated .gitignore to exclude Python cache files, virtual environments, and development artifacts
- Complete motorcycle adventure community website with:
  * Interactive Romania map with GPX route plotting
  * Advanced post creation with cover images, sections, highlights
  * User authentication and authorization system
  * Community features with likes and comments
  * Responsive design with blue-purple-teal gradient theme
  * Docker and production deployment configuration
  * SQLite database with proper models and relationships
  * Image and GPX file upload handling
  * Modern UI with improved form layouts and visual feedback

Technical stack:
- Flask 3.0.0 with SQLAlchemy, Flask-Login, Flask-Mail, Flask-WTF
- Jinja2 templates with Tailwind CSS styling
- Leaflet.js for interactive mapping
- PostgreSQL/SQLite database support
- Docker containerization with Nginx reverse proxy
- Gunicorn WSGI server for production

Project is now production-ready Flask application focused on motorcycle adventure sharing in Romania.
2025-07-23 17:20:52 +03:00

48 lines
1.5 KiB
Python

from flask import Flask
from app.extensions import db, migrate, login_manager, mail
from config import config
import os
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