Spaces:
Sleeping
Sleeping
Ezhil
commited on
Commit
·
7791260
1
Parent(s):
6f7e4e5
added few files
Browse files- .gitignore +1 -0
- Dockerfile +1 -1
- api/__pycache__/main.cpython-310.pyc +0 -0
- api/main.py +20 -0
- modules/__pycache__/continents.cpython-310.pyc +0 -0
- modules/continents.py +11 -0
- requirements.txt +0 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.venv
|
Dockerfile
CHANGED
|
@@ -19,6 +19,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
# Run FastAPI and Streamlit in parallel
|
| 22 |
-
CMD ["uvicorn" ,"main:app","--host" ,"0.0.0.0", "--port", "7860"]
|
| 23 |
|
| 24 |
|
|
|
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
# Run FastAPI and Streamlit in parallel
|
| 22 |
+
CMD ["uvicorn" ,"backend.api.main:app","--host" ,"0.0.0.0", "--port", "7860"]
|
| 23 |
|
| 24 |
|
api/__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (766 Bytes). View file
|
|
|
api/main.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
app = FastAPI()
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__),"../..","backend"))
|
| 6 |
+
sys.path.append(src_directory)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
from modules import continents
|
| 10 |
+
|
| 11 |
+
df = continents.process_data()
|
| 12 |
+
|
| 13 |
+
@app.get("/")
|
| 14 |
+
def home():
|
| 15 |
+
return {"message": "Welcome World"}
|
| 16 |
+
|
| 17 |
+
@app.get("/continents")
|
| 18 |
+
def display_continents():
|
| 19 |
+
continent = continents.get_continents(df)
|
| 20 |
+
return continent.tolist()
|
modules/__pycache__/continents.cpython-310.pyc
ADDED
|
Binary file (524 Bytes). View file
|
|
|
modules/continents.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
file_path = "./data/world_population.csv"
|
| 4 |
+
|
| 5 |
+
def process_data():
|
| 6 |
+
data_frame = pd.read_csv(file_path)
|
| 7 |
+
return data_frame
|
| 8 |
+
|
| 9 |
+
def get_continents(data_frame):
|
| 10 |
+
continents = data_frame['Continent'].unique()
|
| 11 |
+
return continents
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|