import streamlit as st import requests st.title("PDF Extraction App") st.write("Upload a PDF file to extract correct answers and options using the backend service.") # File uploader widget for PDF files uploaded_file = st.file_uploader("Choose a PDF file", type=["pdf"]) if uploaded_file is not None: if st.button("Extract Answers"): with st.spinner("Processing the file, please wait..."): try: # Prepare the file payload files = { "file": (uploaded_file.name, uploaded_file.read(), "application/pdf") } # Make a POST request to the FastAPI endpoint response = requests.post( "https://hammad712-grading.hf.space/extract-answers/", files=files ) # Check for successful response if response.status_code == 200: result = response.json() st.success("Extraction successful!") st.json(result) else: st.error(f"Error: {response.text}") except Exception as e: st.error(f"An error occurred: {e}")