Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EB Flask does not recognize static files

I'm having issue with hosting Flask App on AWS with Elastic Beanstalk. I followed document on AWS(which seems a little old?), and did some workaround suggested here. It works if I have this folder structure:

--application.py
 /static
 /templates
 requirements.txt
 .ebextensions
 .elasticbeanstalk

However, I want to make my application more structured. So I moved my folder structure to and it stopped working

--application.py
--.ebxtensions
--.elasticbeanstalk
  /app
     - __init__.py
     - /static
     - /templates

What I have tried is changing the settings in optionsettings.myapp-env, suggested here. But I got no luck.

(P.S. App works fine except not recognizing the static files folder)

Any help would be appreciated!

like image 918
xbb Avatar asked Mar 15 '14 15:03

xbb


Video Answer


2 Answers

Looks like you need to change the path mapping to: "/static/": "app/static/"

This mapping maps the virtual (what you refer in your html) to the directory structure. Since you have changed the dirs, now you need to change the mapping too.

Alternatively you can do the same conf in the AWS Beanstalk web console as well. Need not do in the configuration files.

like image 190
Sony Kadavan Avatar answered Oct 20 '22 16:10

Sony Kadavan


This seems to be the most recent incarnation of this question and I figured I'd chime in since this just killed me for hours trying to figure out what the heck was wrong because my configuration settings were fine and the error logs and request logs didn't show any problems. I finally opened the developer console and saw I was getting an ERR_BLOCKED_BY_CLIENT for all of my static assets. Ghostery apparently treats elastic beanstalk as a cross-domain analytics tracker, so yet another gotcha that probably needs to be documented somewhere. It's simple enough to turn that off on my end, but I'm only running a site for fun. I'm not sure what you would do if you try to deploy an actual product to elastic beanstalk and Ghostery blocks all of your static assets. Your clients are probably just going to think your site sucks and won't think to look. I guess you better bundle it all directly or use a CDN.

like image 37
Adam Acosta Avatar answered Oct 20 '22 17:10

Adam Acosta