import os from subprocess import Popen # This script tells the Hugging Face environment to run your FastAPI app # on the correct port, which is necessary when using the Gradio SDK template. # Set the port FastAPI should listen on (HF requires 7860) os.environ['PORT'] = '7860' # Start the uvicorn server to host the FastAPI application # api_app:app refers to the 'app' variable inside your 'api_app.py' file # --host 0.0.0.0 is necessary for external access Popen(["uvicorn", "api_app:app", "--host", "0.0.0.0", "--port", "7860"])