Spaces:
Running
Running
Set production backend URL
Browse files- main_streamlit.py +20 -18
main_streamlit.py
CHANGED
|
@@ -8,26 +8,28 @@ load_dotenv()
|
|
| 8 |
st.set_page_config(layout="wide", page_title="Jan-Contract Unified Assistant", page_icon="⚖️")
|
| 9 |
|
| 10 |
# Backend Configuration
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
with st.sidebar:
|
| 14 |
-
st.
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
# Only strip trailing slash if it exists
|
| 33 |
if BACKEND_URL.endswith("/"):
|
|
|
|
| 8 |
st.set_page_config(layout="wide", page_title="Jan-Contract Unified Assistant", page_icon="⚖️")
|
| 9 |
|
| 10 |
# Backend Configuration
|
| 11 |
+
# Default to the production Railway URL
|
| 12 |
+
PRODUCTION_URL = "https://jan-contract-production.up.railway.app"
|
| 13 |
+
default_url = os.getenv("BACKEND_URL", PRODUCTION_URL)
|
| 14 |
|
| 15 |
with st.sidebar:
|
| 16 |
+
with st.expander("⚙️ Connection Settings"):
|
| 17 |
+
BACKEND_URL = st.text_input(
|
| 18 |
+
"Backend API URL",
|
| 19 |
+
value=default_url,
|
| 20 |
+
help="URL of the deployed Jan-Contract API"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Test Connection
|
| 24 |
+
if st.button("Test Connection"):
|
| 25 |
+
try:
|
| 26 |
+
resp = requests.get(f"{BACKEND_URL}/health", timeout=10)
|
| 27 |
+
if resp.status_code == 200:
|
| 28 |
+
st.success("✅ Connected!")
|
| 29 |
+
else:
|
| 30 |
+
st.error(f"❌ Error: {resp.status_code}")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
st.error(f"❌ Failed: {e}")
|
| 33 |
|
| 34 |
# Only strip trailing slash if it exists
|
| 35 |
if BACKEND_URL.endswith("/"):
|