Datathon / ui.py
Sathvik-kota's picture
Upload folder using huggingface_hub
5566fd6 verified
# ui_streamlit.py
import streamlit as st
import requests
import json
API_URL = "https://<username>-<space-name>.hf.space/extract-bill-data"
st.title("Bajaj Bill Extraction - Demo UI")
document_url = st.text_input("Document URL")
if st.button("Extract Bill Data"):
if not document_url.strip():
st.warning("Please enter a document URL.")
else:
with st.spinner("Calling API..."):
try:
payload = {"document": document_url}
resp = requests.post(API_URL, json=payload, timeout=60)
if resp.status_code != 200:
st.error(f"API returned status code {resp.status_code}")
st.text(resp.text)
else:
data = resp.json()
st.success("API call successful!")
st.subheader("Raw JSON Response")
st.code(json.dumps(data, indent=2))
except Exception as e:
st.error(f"Error calling API: {e}")