Spaces:
Runtime error
Runtime error
from typing import Union | |
import csv | |
from fastapi import FastAPI | |
from fastapi.staticfiles import StaticFiles | |
from fastapi.responses import FileResponse | |
app = FastAPI() | |
def load_data(filename): | |
myList = [] | |
with open(filename) as numbers: | |
numbers_data = csv.reader(numbers,delimiter=',') | |
next(numbers_data) #skip the header | |
for row in numbers_data: | |
myList.append(row) | |
return myList | |
new_list = load_data('country.csv') | |
def getData(): | |
return {"data": new_list} | |
app.mount('/',StaticFiles(directory="static",html=True),name="static") | |
def index() -> FileResponse: | |
return FileResponse('/app/static/index.html',media_type="text/html") | |