SpatialParse / app.py
Shunfeng Zheng
Add Streamlit demo
69eefd7
raw
history blame
989 Bytes
import streamlit as st
import requests
st.title("Spatial Parser Demo")
# 密码验证
password = st.text_input("Enter access password:", type="password")
if password != "demo1234":
st.warning("Please enter the correct password.")
st.stop()
# 输入框
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}")