first commit
This commit is contained in:
56
app.py
Normal file
56
app.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# app.py - Main Flask Application Entry Point
|
||||
|
||||
import os
|
||||
from flask import Flask
|
||||
|
||||
from config import SECRET_KEY, STATIC_FOLDER, STATIC_URL_PATH, TTS_API_URL, TTS_API_KEY, DATABASE
|
||||
from db import init_app as init_db
|
||||
from routes import register_blueprints
|
||||
|
||||
|
||||
def create_app():
|
||||
"""Application factory function."""
|
||||
app = Flask(__name__, static_folder=STATIC_FOLDER, static_url_path=STATIC_URL_PATH)
|
||||
|
||||
# Configure app
|
||||
app.secret_key = SECRET_KEY
|
||||
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
||||
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
||||
app.config['SESSION_COOKIE_SECURE'] = os.getenv('FLASK_ENV') == 'production'
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = 86400 # 24 hours
|
||||
app.config['PREFERRED_URL_SCHEME'] = 'https'
|
||||
|
||||
# Trust the reverse proxy headers from Coolify/Traefik
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
|
||||
|
||||
# Initialize database
|
||||
init_db(app)
|
||||
|
||||
# Register all blueprints
|
||||
register_blueprints(app)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
# Create app instance
|
||||
app = create_app()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("=" * 60)
|
||||
print("🎧 Audiobook Maker Pro v4 Starting...")
|
||||
print("=" * 60)
|
||||
print(f"📍 TTS API Server: {TTS_API_URL}")
|
||||
print(f"📍 API Key: {'✅ Configured' if TTS_API_KEY else '❌ NOT CONFIGURED!'}")
|
||||
print(f"📍 Database: {DATABASE}")
|
||||
print(f"📍 Static Files: {STATIC_FOLDER}")
|
||||
print(f"📍 Default Admin: admin / admin123")
|
||||
print("-" * 60)
|
||||
|
||||
if not TTS_API_KEY:
|
||||
print("⚠️ WARNING: TTS_API_KEY not set in .env file!")
|
||||
|
||||
print("=" * 60)
|
||||
|
||||
app.run(debug=True, port=5009)
|
||||
Reference in New Issue
Block a user