Ezhil
commited on
Commit
·
13745e6
1
Parent(s):
c5b44b3
Fixed Hugging Face timeout issue
Browse files- Dockerfile +10 -8
- app.py +3 -0
- requirements.txt +0 -0
Dockerfile
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy the
|
| 8 |
-
COPY
|
| 9 |
|
| 10 |
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# Expose the
|
| 15 |
-
EXPOSE
|
| 16 |
|
| 17 |
-
# Run the
|
| 18 |
-
CMD ["streamlit", "run", "app.py", "--server.port=
|
|
|
|
| 1 |
+
# Use a lightweight Python image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy only the requirements file first (to optimize build cache)
|
| 8 |
+
COPY requirements.txt ./
|
| 9 |
|
| 10 |
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Copy the rest of the application files
|
| 14 |
+
COPY . .
|
| 15 |
|
| 16 |
+
# Expose the correct port for Hugging Face Spaces
|
| 17 |
+
EXPOSE 7860
|
| 18 |
|
| 19 |
+
# Run Streamlit app on the correct port
|
| 20 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
app.py
CHANGED
|
@@ -4,6 +4,9 @@ import requests
|
|
| 4 |
# FastAPI backend URL (assuming it's running on localhost)
|
| 5 |
API_URL = "https://ezhil24-backend.hf.space/"
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Define function to get continent stats from FastAPI backend
|
| 8 |
def get_continent_stats(continent):
|
| 9 |
response = requests.get(f"{API_URL}{continent}/")
|
|
|
|
| 4 |
# FastAPI backend URL (assuming it's running on localhost)
|
| 5 |
API_URL = "https://ezhil24-backend.hf.space/"
|
| 6 |
|
| 7 |
+
# Streamlit config for Hugging Face compatibility
|
| 8 |
+
st.set_page_config(page_title="World Population Statistics", layout="wide")
|
| 9 |
+
|
| 10 |
# Define function to get continent stats from FastAPI backend
|
| 11 |
def get_continent_stats(continent):
|
| 12 |
response = requests.get(f"{API_URL}{continent}/")
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|