HarishMaths commited on
Commit
fbe740a
·
verified ·
1 Parent(s): a9998bf

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # streamlit_app.py
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("Hugging Face Flask API Connector")
6
+
7
+ user_input = st.text_input("Enter text to send to Flask API:")
8
+
9
+ if st.button("Send to API"):
10
+ if user_input:
11
+ api_url = "https://HarishMaths-Backend.hf.space/predict" # Replace with your actual URL
12
+ payload = {"text": user_input}
13
+
14
+ try:
15
+ response = requests.post(api_url, json=payload)
16
+ if response.status_code == 200:
17
+ result = response.json()
18
+ st.success(f"Prediction: {result['prediction']}")
19
+ else:
20
+ st.error(f"API Error: {response.status_code}")
21
+ except Exception as e:
22
+ st.error(f"Request failed: {e}")