File size: 757 Bytes
fbe740a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# streamlit_app.py
import streamlit as st
import requests

st.title("Hugging Face Flask API Connector")

user_input = st.text_input("Enter text to send to Flask API:")

if st.button("Send to API"):
    if user_input:
        api_url = "https://HarishMaths-Backend.hf.space/predict"  # Replace with your actual URL
        payload = {"text": user_input}

        try:
            response = requests.post(api_url, json=payload)
            if response.status_code == 200:
                result = response.json()
                st.success(f"Prediction: {result['prediction']}")
            else:
                st.error(f"API Error: {response.status_code}")
        except Exception as e:
            st.error(f"Request failed: {e}")