from app import create_app
from app.config import Config
import os

# Warn (not crash) if ffmpeg is missing
Config.validate_paths()
app = create_app()

if __name__ == '__main__':
    cert_path = os.path.join(os.path.dirname(__file__), 'certs', 'cert.pem')
    key_path = os.path.join(os.path.dirname(__file__), 'certs', 'key.pem')

    ssl_ctx = None
    if os.path.exists(cert_path) and os.path.exists(key_path):
        ssl_ctx = (cert_path, key_path)
    else:
        print("SSL certificates not found — starting without SSL (HTTP only).")

    app.run(
        debug=True,
        host='0.0.0.0',
        port=5003,
        ssl_context=ssl_ctx,
    )
