File size: 1,021 Bytes
5566fd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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}")