SpatialParse / app.py
Shunfeng Zheng
Add Streamlit demo
e9c69f6
raw
history blame
813 Bytes
import streamlit as st
import requests
st.title("Spatial Parser Demo")
# 输入框
text = st.text_area("Enter your spatial description:")
if st.button("Submit"):
with st.spinner("Calling secure backend..."):
try:
response = requests.post(
"https://dsbb0707--spatialparse-back.hf.space/predict",
json={"text": text},
timeout=20
)
try:
st.write("Raw response:", response.text)
result = response.json().get("result", "No result returned.")
except Exception as e:
st.error(f"Backend error: {e}\nRaw response: {response.text}")
st.success(f"Parsed Output:\n\n{result}")
except Exception as e:
st.error(f"Backend error: {e}")