use a css stylesheet on a jinja2 template

后端 未结 5 715
盖世英雄少女心
盖世英雄少女心 2020-12-28 13:01

I am making a website using html, css, flask and jinja2.

I have a page working on a flask server, the buttons and labels etc. are displayed, but the css stylesheet I

5条回答
  •  生来不讨喜
    2020-12-28 14:03

    All public files (the ones that are not processed, like templates or python files) should be placed into dedicated static folders. By default, Jinja2 has one static folder called static.

    This should fix your problem:

    1. Move /templates/styles.css to /static/styles.css

    2. Update your code with following code, that will be translated into correct file location:

      
      

    More info on static files in Jinja2 is here.

提交回复
热议问题