geeksiddhant commited on
Commit
595e8cd
·
1 Parent(s): fe8e5bf

Update API URL

Browse files
Files changed (2) hide show
  1. Spacefile +3 -3
  2. app.py +3 -3
Spacefile CHANGED
@@ -6,9 +6,9 @@ configuration:
6
  services:
7
  - name: fastapi
8
  dist: python
9
- port: 8000
10
- command: uvicorn app.main:app --host 0.0.0.0 --port 8000
11
  - name: streamlit
12
  dist: python
13
  port: 8501
14
- command: streamlit run frontend/app.py
 
6
  services:
7
  - name: fastapi
8
  dist: python
9
+ port: 7860
10
+ command: uvicorn app.main:app --host 0.0.0.0 --port 7860 --root-path /api
11
  - name: streamlit
12
  dist: python
13
  port: 8501
14
+ command: streamlit run app.py
app.py CHANGED
@@ -19,10 +19,10 @@ st.set_page_config(
19
  class APIClient:
20
  def __init__(self):
21
  # Get the Hugging Face Space URL from environment or use localhost
22
- space_url = os.getenv("SPACE_ID") # Hugging Face Spaces provides this automatically
23
- if space_url:
24
  # In Hugging Face Spaces, the FastAPI service will be available at port 8000
25
- self.base_url = f"https://{space_url}-8000.hf.space"
26
  else:
27
  # Local development
28
  self.base_url = "http://localhost:8000"
 
19
  class APIClient:
20
  def __init__(self):
21
  # Get the Hugging Face Space URL from environment or use localhost
22
+ space_id = os.getenv("SPACE_ID") # Hugging Face Spaces provides this automatically
23
+ if space_id:
24
  # In Hugging Face Spaces, the FastAPI service will be available at port 8000
25
+ self.base_url = f"https://{space_id}.hf.space/api" # Updated URL format
26
  else:
27
  # Local development
28
  self.base_url = "http://localhost:8000"