lundi 2 août 2021

Flask can't find local static files even though they exist and the specified path is correct

I use render_template in conjunction with Flask to render an html file, index.html, which in turn references a CSS stylesheet, "templatemo-style.css". Within that css file, references are made to other local files like images and so on.

The folder structure looks like this:

/PARENT FOLDER
   /templates
      /index.html
   /static
      /assets
         /images
            /various files

Within the "assets" folder, there is sub folder called "css" which houses the css file.

The css file makes a call to the following url to grab the website's banner image:

background-image: url(../assets/images/main-banner.jpg);

The problem is, when I RUN the flask application, I get the following 404 error in my terminal: 127.0.0.1 - - [02/Aug/2021 13:13:51] "GET /static/images/main-banner.jpg HTTP/1.1" 404 -

For some reason, the application isn't calling the path that I specified in the code. I've searched all over the code in various different files for the place where this mysterious call is made and I can't find it anywhere. Even if I comment out my "background-image:" line above, I still get the same error. I should note that for the front-end i'm using a css/bootstrap template that I found online and then modified to my liking. I've searched the js code as well and that call isn't made there either.

I'm completely stumped and have no idea where this mystery call is coming from. Anybody have any possible ideas? Thanks




Aucun commentaire:

Enregistrer un commentaire