python-eel/Eel

How to add my_css.css file into jinja2 base.html templates?

Open

#490 建立於 2021年5月31日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)Python (570 fork)batch import
help wanted

倉庫指標

Star
 (5,980 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

What needs to be written in the base.html file or in the hello.html file in order to include the css file, since I don't get the body background-color? thanks for any help

There is a my folder structure: jinja --web --static my_css.css --templates base.html hello.html hello.py

**hello.py** 
import eel

eel.init(r'jinja2_templates/web')
eel.start('templates/hello.html', size=(300, 200), jinja_templates='templates') 


**my_css.css**
body {
background-color: red;
}

**base.html**
```html
<!DOCTYPE html>
<html lang="ru">
<head>
    <title>{% block title %}{% endblock %}</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/jinja2_templates/web/static/my_css.css">
    
    <script type="text/javascript" src="/leap_year_app/Lib/site-packages/eel/eel.js"></script>
</head>
<body>
    
    <h1>Hello</h1>
</body>
</html>

hello.html

{% extends 'base.html' %} 
{% block title %}Hello, World!{% endblock %}

貢獻者指南