November 2014
Intermediate to advanced
258 pages
5h 15m
English
Organizing static files such as JavaScript, stylesheets, images, and so on efficiently is always a matter of concern for all web frameworks.
Flask recommends a specific way to organize static files in our application:
my_app/
- app.py
- config.py
- __init__.py
- static/
- css/
- js/
- images/
- logo.pngWhile rendering them in templates (say, the logo.png file), we can refer to the static files using the following line of code:
<img src='/static/images/logo.png'>
If there exists a folder named static at the application's root level, that is, at the same level as app.py, then Flask will automatically read the contents of the folder without any extra configuration.
Alternatively, we can ...
Read now
Unlock full access