#!/usr/bin/env python import os import argparse from hypercorn.config import Config from hypercorn.asyncio import serve import asyncio from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() from app import app if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run the Video Query backend server") parser.add_argument("--host", default="0.0.0.0", help="Host IP address to bind to") parser.add_argument("--port", type=int, default=5010, help="Port to bind to") args = parser.parse_args() config = Config() config.bind = [f"{args.host}:{args.port}"] # Set large file upload size limit (5GB) config.h11_max_incomplete_size = 5 * 1024 * 1024 * 1024 # Increase timeouts for large uploads config.keep_alive_timeout = 3600 # 60 minutes # Set configuration values to help with large file uploads config.websocket_ping_interval = 20 # Send ping frames every 20 seconds to keep connection alive config.graceful_timeout = 3600 # Allow up to 1 hour for requests to complete during shutdown # Other helpful settings for large files config.worker_class = "asyncio" config.backlog = 100 config.read_timeout = 3600 # 60 minutes config.write_timeout = 3600 # 60 minutes # Run with Hypercorn asyncio.run(serve(app, config))