Spaces:
Sleeping
Sleeping
Commit ·
595e8cd
1
Parent(s): fe8e5bf
Update API URL
Browse files
Spacefile
CHANGED
|
@@ -6,9 +6,9 @@ configuration:
|
|
| 6 |
services:
|
| 7 |
- name: fastapi
|
| 8 |
dist: python
|
| 9 |
-
port:
|
| 10 |
-
command: uvicorn app.main:app --host 0.0.0.0 --port
|
| 11 |
- name: streamlit
|
| 12 |
dist: python
|
| 13 |
port: 8501
|
| 14 |
-
command: streamlit run
|
|
|
|
| 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 |
-
|
| 23 |
-
if
|
| 24 |
# In Hugging Face Spaces, the FastAPI service will be available at port 8000
|
| 25 |
-
self.base_url = f"https://{
|
| 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"
|