简体   繁体   中英

Elastic Beanstalk Flask Application - Static files not found

I've been attempting to solve this issue for the past few hours with little success. Essentially, I have a flask application that works fine locally, but when deployed as a docker image to Elastic Beanstalk, all the files under the static folder aren't being picked up; leaving me with barebones html pages.

What I've tried: After Googling for quite some time (lots of old responses), it looks like I need to tamper with the config files. I tried to mess around in eb config, trying to do something like this:

[aws:elasticbeanstalk:container:python:staticfiles] /static/=app/static/ (from Static assets don't show up for flask on elastic beanstalk )

but it says that it doesn't recognize OptionalName "/static/"; old version of EB show that there is a way to specific the path of the static folders in GUI interface, but that doesn't seem to exist anymore under Configurations -> Software.

This is the layout of my files:

  • Dockerfile

  • App

    • app.py

    • templates/

    • index.html

    • form.html

    ....

    • static/

    • css

    • images

    • js

    • vendor ....

At the top of my html files, I reference my css and js files as such:

Any help in the right direction would be appreciated!

Well, now this seems a bit silly. I looked more into the console and found that I was getting a series of Failed to load resource: net::ERR_BLOCKED_BY_CLIENT on the client side; I ended up disabling Adblock and it worked; future reloadings also work with or without it disabled (I assume because of Google caching it). I doubt anyone would have this specific issue, but if you do, check to make sure that you have a similar Flask folder structure like above, and disable any extensions that might interfere with the loading of static files. Now my next step is to look into figuring out how to make adblock not try and block these files to begin with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM