mediguide-api / streamlit_app.py
phoner45's picture
Create streamlit_app.py
a4753d2 verified
raw
history blame
1.06 kB
import json
import requests
import streamlit as st
# Set the title of the app
st.title("Medical Prediction Model")
# Instruction text
st.write("Enter 32 features for prediction:")
# Create 32 input fields for user input
inputs = []
for i in range(32):
value = st.number_input(f"Feature {i + 1}", min_value=0, step=1)
inputs.append(value)
# Button to make prediction
if st.button("Predict"):
# Prepare the data for the request
input_data = {"features": inputs}
# Set the URL for your FastAPI backend
url = "http://localhost:8501/predict" # Replace with your actual URL if deployed
# Make a POST request
response = requests.post(url, json=input_data) # Send the wrapped input_data
# Check the response status code
if response.status_code == 200:
# Get the JSON response
prediction = response.json()
# Display the prediction results
st.success("Prediction Results:")
st.json(prediction)
else:
st.error(f"Error: {response.status_code} - {response.text}")