静态资产不露面瓶上的弹性魔豆 [英] Static assets don't show up for flask on elastic beanstalk
问题描述
你如何获得AWS弹性魔豆认识到你的静态资产,在瓶中的应用程序?我做了标准/.ebextensions/python.config夫妇YAML线一拉:
How do you get aws elastic beanstalk to recognize your static assets in your flask app? I did the standard /.ebextensions/python.config couple of YAML lines a la:
option_settings:
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
我的所有调用模板中的资产被包裹在{{url_for('静',文件名='IMG / office.jpg')}}类型的东西。
All of my calls to assets in templates are wrapped in "{{url_for('static', filename='img/office.jpg')}}" type things.
但是,没有图像,样式或JavaScript显示出来的页面加载。下面是一个例子日志文件404。 IP - - [25 /二月/ 2013:21:48:13 +0000]GET /static/css/bootstrap.css HTTP / 1.1404 328的 http://xyz.elasticbeanstalk.com/
But no images, styles or javascript shows up on page load. Here is an example log file 404. IP - - [25/Feb/2013:21:48:13 +0000] "GET /static/css/bootstrap.css HTTP/1.1" 404 328 "http://xyz.elasticbeanstalk.com/"
我失去了一些东西明显?一切伟大的运行在我的地方,只是静态的资产不载有一次,我的git aws.push
Am I missing something obvious? Everything runs great on my local, just static assets dont load once i git aws.push
推荐答案
我不知道,你把你的静态文件,但由于我的是典型的应用程序/静态
,我有:
I'm not sure where you put your static files, but since mine are typically in app/static
, I have:
[aws:elasticbeanstalk:container:python:staticfiles]
/static/=app/static/
/favicon.ico=app/static/favicon.ico
[aws:elasticbeanstalk:container:python]
StaticFiles=/static/=app/static/,/favicon.ico=app/static/favicon.ico
这两个区似乎是重要的。 (后者部分有其他的东西在里面太多,但我已经离开了这一点。)其实我有两个资源的路径在这里,无论是 /静态/
目录和顶级水平 /favicon.ico
文件愚蠢的旧的浏览器总是要求。
Both sections seem to be important. (The latter section has other stuff in it too but I've left that out.) I actually have two resource paths here, both the /static/
directory and the top-level /favicon.ico
file that dumb old browsers always ask for.
这篇关于静态资产不露面瓶上的弹性魔豆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!