python - Flask Templates couldn't load css -
i followed tutorial develop templates flask http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-ii-templates
my file tree next one:
/static /js bootstrap.min.js jquery_1.11.3.js /css bootstrap.min.css /images /templates index.html /python_venv server.py
server.py code:
@app.route('/subdomain/') def getprevisionpoblacion(): return render_template('index.html')
and css link inside index.html code following:
<script src="/static/js/bootstrap.min.js"></script> <link rel="stylesheet" href="/static/css/bootstrap.min.css"/> <script src="/static/js/jquery_1.11.3.js"></script>
nginx config:
location /subdomain/{ root /apps/subdomain/static; uwsgi_pass unix:///tmp/subdomain.sock; include uwsgi_params; }
when check on chrome, index didn't load css files. checked network developer's tools , error 404. tried similar code saw on unresolved question without success inline css background:url() not working in jinja2 template
any ?
the problem server.
i had serve static folder flask template can load css.
i wrote in nginx config file next:
location /subdomain/static)/ { root /opt/apps/content_folder/static; }
i don't use url_for() function y wrote resource's url as:
static/css/my_css_template.css
finally check out @app.route() inside file render template correct flask template access css, images , js.
Comments
Post a Comment