Skip to content

Commit 54e38eb

Browse files
committed
working prototype added
1 parent 7a5b6ea commit 54e38eb

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# main.py
2+
from fastapi import FastAPI
3+
from fastapi.middleware.cors import CORSMiddleware
4+
from fastapi.staticfiles import StaticFiles
5+
6+
app = FastAPI()
7+
8+
# Allow CORS for all origins for development purposes
9+
app.add_middleware(
10+
CORSMiddleware,
11+
allow_origins=["*"],
12+
allow_credentials=True,
13+
allow_methods=["*"],
14+
allow_headers=["*"],
15+
)
16+
17+
# Mount the streamlit app as a static file
18+
app.mount("/streamlit", StaticFiles(directory="src", html=True), name="streamlit")

src/app.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# src/app.py
2+
import streamlit as st
3+
import pandas as pd
4+
from fastapi import HTTPException
5+
6+
# Load the Iris dataset
7+
@st.cache_data
8+
def load_data():
9+
try:
10+
df = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header=None)
11+
df.columns = ["sepal_length", "sepal_width", "petal_length", "petal_width", "class"]
12+
return df
13+
except Exception as e:
14+
raise HTTPException(status_code=500, detail=f"Error loading data: {str(e)}")
15+
16+
df = load_data()
17+
18+
# Streamlit app
19+
def main():
20+
st.title("Iris Dataset EDA")
21+
22+
# Create buttons in the sidebar for each page
23+
raw_data_button = st.sidebar.button("Raw Data")
24+
summary_stats_button = st.sidebar.button("Summary Statistics")
25+
class_distribution_button = st.sidebar.button("Class Distribution")
26+
27+
# Display content based on clicked button
28+
if raw_data_button:
29+
st.subheader("Raw Dataset")
30+
st.write(df)
31+
32+
if summary_stats_button:
33+
st.subheader("Summary Statistics")
34+
st.write(df.describe())
35+
36+
if class_distribution_button:
37+
st.subheader("Class Distribution")
38+
class_counts = df["class"].value_counts()
39+
st.bar_chart(class_counts)
40+
41+
if __name__ == "__main__":
42+
main()

0 commit comments

Comments
 (0)