Amodit commited on
Commit
bd7cb1d
·
1 Parent(s): 0d649c6

Set production backend URL

Browse files
Files changed (1) hide show
  1. 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
- default_url = os.getenv("BACKEND_URL", "http://127.0.0.1:8000")
 
 
12
 
13
  with st.sidebar:
14
- st.header("⚙️ Configuration")
15
- BACKEND_URL = st.text_input(
16
- "Backend API URL",
17
- value=default_url,
18
- help="Paste your Vercel/Railway deployment URL here (e.g., https://your-project.vercel.app)"
19
- )
20
-
21
- # Test Connection
22
- if st.button("Test Connection"):
23
- try:
24
- resp = requests.get(f"{BACKEND_URL}/health", timeout=5)
25
- if resp.status_code == 200:
26
- st.success("✅ Connected!")
27
- else:
28
- st.error(f"❌ Error: {resp.status_code}")
29
- except Exception as e:
30
- st.error(f"❌ Failed: {e}")
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("/"):