Shunfeng Zheng commited on
Commit
1d49548
·
1 Parent(s): e9c69f6

Add Streamlit demo

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -1,26 +1,19 @@
1
- import streamlit as st
2
  import requests
 
3
 
4
  st.title("Spatial Parser Demo")
5
 
6
-
7
-
8
- # 输入框
9
  text = st.text_area("Enter your spatial description:")
10
 
11
  if st.button("Submit"):
12
- with st.spinner("Calling secure backend..."):
13
  try:
14
  response = requests.post(
15
- "https://dsbb0707--spatialparse-back.hf.space/predict",
16
- json={"text": text},
17
  timeout=20
18
  )
19
- try:
20
- st.write("Raw response:", response.text)
21
- result = response.json().get("result", "No result returned.")
22
- except Exception as e:
23
- st.error(f"Backend error: {e}\nRaw response: {response.text}")
24
  st.success(f"Parsed Output:\n\n{result}")
25
  except Exception as e:
26
  st.error(f"Backend error: {e}")
 
 
1
  import requests
2
+ import streamlit as st
3
 
4
  st.title("Spatial Parser Demo")
5
 
 
 
 
6
  text = st.text_area("Enter your spatial description:")
7
 
8
  if st.button("Submit"):
9
+ with st.spinner("Calling backend..."):
10
  try:
11
  response = requests.post(
12
+ "https://dsbb0707--spatialparse-gradio.hf.space/run/predict",
13
+ json={"data": [text]},
14
  timeout=20
15
  )
16
+ result = response.json()["data"][0]
 
 
 
 
17
  st.success(f"Parsed Output:\n\n{result}")
18
  except Exception as e:
19
  st.error(f"Backend error: {e}")