Les fichiers statiques sont généralement placés dans un dossier /static
/home/marc/mon_projet ├── venv │ └── ... ├── static │ ├── css │ │ ├── styles.css │ │ └── ... │ ├── img │ │ ├── favicon.png │ │ └── ... │ └── js │ ├── main.js │ └── ... └── app.py
Ils sont inclus par un appel à url_for :
<head> <link rel="icon" type="image/png" href="{{ url_for('static', filename='img/favicon.png') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}"> </head> <body> ... <script src="{{ url_for('static', filename='js/main.js') }}"></script> </body>