# Hugging Face Spaces entry point for the backend API import os import sys from threading import Thread from time import sleep # Add the parent directory to path for imports sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from backend.api import app if __name__ == "__main__": # Start the Flask app in a separate thread # This is needed because Hugging Face Spaces may require the main thread for other purposes def run_app(): app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)), debug=False) # Start the Flask app in a separate thread thread = Thread(target=run_app) thread.start() # Keep the main thread alive try: while True: sleep(1) except KeyboardInterrupt: print("Shutting down...")