File size: 546 Bytes
0cd65f4
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
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"])