HumanMachine74 commited on
Commit
e241815
·
verified ·
1 Parent(s): 3485f51

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +8 -16
  2. app.py +34 -0
  3. requirements.txt +3 -2
README.md CHANGED
@@ -1,19 +1,11 @@
 
1
  ---
2
- title: SuperKart Frontend App
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: front end app
12
  ---
13
 
14
- # Welcome to Streamlit!
15
-
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
-
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
1
+
2
  ---
3
+ title: SuperKart Data Viewer
4
+ emoji: 📊
5
+ colorFrom: blue
6
+ colorTo: purple
7
+ sdk: streamlit
 
 
 
 
 
8
  ---
9
 
10
+ # SuperKart Data Viewer
11
+ This is a simple Streamlit application that fetches and displays data from a Flask API.
 
 
 
 
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+ import pandas as pd
5
+ from datetime import datetime
6
+
7
+ st.title('SuperKart Data Viewer')
8
+ st.markdown('A simple Streamlit app to fetch data from the Flask API deployed on Hugging Face.')
9
+
10
+ # Define the API endpoint URL.
11
+ # *** REPLACE with your actual deployed Flask API URL ***
12
+ api_url = "https://<YOUR-FLASK-SPACE-ID>.hf.space/data"
13
+
14
+ def fetch_data():
15
+ try:
16
+ response = requests.get(api_url)
17
+ if response.status_code == 200:
18
+ return response.json()
19
+ else:
20
+ st.error(f"Error fetching data from API: {response.status_code} - {response.text}")
21
+ return None
22
+ except requests.exceptions.RequestException as e:
23
+ st.error(f"Failed to connect to the API: {e}")
24
+ return None
25
+
26
+ if st.button('Fetch and Process Data'):
27
+ with st.spinner('Fetching and processing data...'):
28
+ data = fetch_data()
29
+ if data:
30
+ df = pd.DataFrame(data)
31
+ df['Years_Since_Establishment'] = datetime.now().year - df['Store_Establishment_Year']
32
+ df['Product_MRP_per_Weight'] = df['Product_MRP'] / df['Product_Weight']
33
+ st.success('Data fetched and processed successfully!')
34
+ st.dataframe(df)
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
- altair
 
2
  pandas
3
- streamlit
 
1
+
2
+ streamlit
3
  pandas
4
+ requests