Trying to read csv file from static folder with python

52 Views Asked by At

I have a flask web app setup with the folder structure below

app
 -website
     -static
         ---example.csv
     -templates
         ---home.html
     -__init__.py
     -views.py
 -main.py

my home.html file where I try to access the csv file using pyscript

<py-script>
file = open("./static/example.csv", mode="r", encoding="utf-8")
</py-script>

I get

FileNotFoundError: [Errno 44] No such file or directory

when I test my app in the browser

I have tried also /static/example.csv, website/static/example.csv, 127.0.0.1:5000/static/example.csv. The last one finds the csv file if I type it in the browser.

0

There are 0 best solutions below