logeswari commited on
Commit
ee3cf7e
·
1 Parent(s): a05b390
Files changed (3) hide show
  1. Dockerfile +17 -0
  2. app.py +53 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a lightweight Python image as the base
2
+ FROM python:3.9-slim
3
+
4
+ # Set the working directory
5
+ WORKDIR /app
6
+
7
+ # Copy the project files to the container
8
+ COPY . /app
9
+
10
+ # Install dependencies
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Expose Streamlit's default port
14
+ EXPOSE 7860
15
+
16
+ # Command to run the Streamlit app
17
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import pandas as pd
4
+
5
+ # Set the FastAPI base URL
6
+ API_URL = "https://logeswari-backapp.hf.space"
7
+
8
+ # Streamlit app title
9
+ st.title("⭐World Population Dashboard")
10
+
11
+ # Sidebar filter for continents
12
+ st.sidebar.header("Filter")
13
+ selected_continent = st.sidebar.selectbox(
14
+ "Select the Continent:",
15
+ ['Asia', 'Africa', 'North America', 'South America', 'Europe', 'Oceania']
16
+ )
17
+
18
+ # Fetch data from the FastAPI endpoint
19
+ if st.sidebar.button("Get Data"):
20
+ # Call FastAPI to get continent data
21
+ response = requests.get(f"{API_URL}/continent/{selected_continent}")
22
+
23
+ if response.status_code == 200:
24
+ data = response.json()
25
+ st.write(data)
26
+
27
+ # Display the continent information
28
+ st.header(f"Data of {data['continent']}")
29
+ st.metric("Total Population", f"{data['total_population']:,}")
30
+ st.metric("Total Area (sq km)", f"{data['total_area']:,}")
31
+ st.metric("Population Density", f"{data['continent_population_density']:.2f}")
32
+ st.subheader("Population Highlights")
33
+ st.write(
34
+ f"Max Population :{data['max_population']['country']} "
35
+ f"({data['max_population']['population']:,})"
36
+ )
37
+ # Country with min population
38
+ st.write(
39
+ f"Min Population:{data['min_population']['country']} "
40
+ f"({data['min_population']['population']:,})"
41
+ )
42
+
43
+ # countries_data=data['countries']
44
+ # country_df = pd.DataFrame(countries_data)
45
+ # st.subheader(f"Population of Countries in {data['continent']}")
46
+ # st.bar_chart(country_df.set_index("Country"))z
47
+ else:
48
+ # Handle errors
49
+ st.error(f"Error: {response.json()['detail']}")
50
+
51
+
52
+ data=pd.read_csv('D:\pandas\world_population (1).csv')
53
+ st.dataframe(data)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ requests
3
+ pandas