Skip to content

Commit 2e31081

Browse files
committed
feat: use conf for streamlit
1 parent 418ad38 commit 2e31081

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

frontend/streamlit/app.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
import requests
44
import streamlit as st
5+
from config import Config
56

67

78
# Page configuration
@@ -15,17 +16,18 @@
1516
if 'search_results' not in st.session_state:
1617
st.session_state.search_results = None
1718

18-
# API endpoints
19-
SEARCH_API_URL = "https://clipabit01--clipabit-server-search-dev.modal.run"
20-
UPLOAD_API_URL = "https://clipabit01--clipabit-server-upload-dev.modal.run"
21-
STATUS_API_URL = "https://clipabit01--clipabit-server-status-dev.modal.run"
22-
LIST_VIDEOS_API_URL = "https://clipabit01--clipabit-server-list-videos-dev.modal.run"
19+
# API endpoints from config
20+
SEARCH_API_URL = Config.SEARCH_API_URL
21+
UPLOAD_API_URL = Config.UPLOAD_API_URL
22+
STATUS_API_URL = Config.STATUS_API_URL
23+
LIST_VIDEOS_API_URL = Config.LIST_VIDEOS_API_URL
24+
NAMESPACE = Config.NAMESPACE
2325

2426

2527
def search_videos(query: str):
2628
"""Send search query to backend."""
2729
try:
28-
resp = requests.get(SEARCH_API_URL, params={"query": query}, timeout=30)
30+
resp = requests.get(SEARCH_API_URL, params={"query": query, "namespace": NAMESPACE}, timeout=30)
2931
if resp.status_code == 200:
3032
return resp.json()
3133
else:
@@ -38,7 +40,7 @@ def search_videos(query: str):
3840
def fetch_all_videos():
3941
"""Fetch all videos from the backend."""
4042
try:
41-
resp = requests.get(LIST_VIDEOS_API_URL, timeout=30)
43+
resp = requests.get(LIST_VIDEOS_API_URL, params={"namespace": NAMESPACE}, timeout=30)
4244
if resp.status_code == 200:
4345
data = resp.json()
4446
return data.get("videos", [])
@@ -50,7 +52,8 @@ def fetch_all_videos():
5052
def upload_file_to_backend(file_bytes: bytes, filename: str, content_type: str | None = None):
5153
"""Upload file to backend via multipart form-data."""
5254
files = {"file": (filename, io.BytesIO(file_bytes), content_type or "application/octet-stream")}
53-
resp = requests.post(UPLOAD_API_URL, files=files, timeout=300)
55+
data = {"namespace": NAMESPACE}
56+
resp = requests.post(UPLOAD_API_URL, files=files, data=data, timeout=300)
5457
return resp
5558

5659

0 commit comments

Comments
 (0)