Application not picking up .css file (flask/python)

前端 未结 10 1861
悲&欢浪女
悲&欢浪女 2020-11-28 03:54

I am rendering a template, that I am attempting to style with an external style sheet. File structure is as follows.

/app
    - app_runner.py
    /services
          


        
10条回答
  •  余生分开走
    2020-11-28 04:11

    You need to have a 'static' folder setup (for css/js files) unless you specifically override it during Flask initialization. I am assuming you did not override it.

    Your directory structure for css should be like:

    /app
        - app_runner.py
        /services
            - app.py 
        /templates
            - mainpage.html
        /static
            /styles
                - mainpage.css
    

    Notice that your /styles directory should be under /static

    Then, do this

    
    

    Flask will now look for the css file under static/styles/mainpage.css

提交回复
热议问题