Spaces:
Sleeping
Sleeping
Venkat V
commited on
Commit
·
b3f0903
1
Parent(s):
4e099cb
patching for api url
Browse files
app.py
CHANGED
@@ -25,15 +25,17 @@ ocr_engine = st.selectbox("Select OCR Engine", ["easyocr", "doctr"], index=0,
|
|
25 |
# Flowchart image uploader
|
26 |
uploaded_file = st.file_uploader("Upload a flowchart image", type=["png", "jpg", "jpeg"])
|
27 |
|
28 |
-
# Backend API URL (defaults to localhost for dev)
|
29 |
-
|
30 |
# Backend API URL handling
|
31 |
-
|
32 |
IS_SPACE = "SPACE_ID" in os.environ
|
33 |
|
34 |
-
|
35 |
-
# In
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# Allow override through environment variable if needed
|
39 |
API_URL = os.getenv("API_URL", API_URL)
|
|
|
25 |
# Flowchart image uploader
|
26 |
uploaded_file = st.file_uploader("Upload a flowchart image", type=["png", "jpg", "jpeg"])
|
27 |
|
|
|
|
|
28 |
# Backend API URL handling
|
29 |
+
# Hugging Face Spaces injects SPACE_ID environment variable
|
30 |
IS_SPACE = "SPACE_ID" in os.environ
|
31 |
|
32 |
+
if IS_SPACE:
|
33 |
+
# In Hugging Face Spaces, construct a URL relative to the current page
|
34 |
+
# This ensures it works with the proxy setup
|
35 |
+
API_URL = "https://venkatviswa-flowchart-to-text.hf.space/process-image"
|
36 |
+
else:
|
37 |
+
# In local dev, we use the full URL with port
|
38 |
+
API_URL = "http://localhost:7860/process-image"
|
39 |
|
40 |
# Allow override through environment variable if needed
|
41 |
API_URL = os.getenv("API_URL", API_URL)
|