Spaces:
Sleeping
Sleeping
| # 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}") | |