[Flask] Chapter 2: Embedding of Static Files

Static file


Insert picture description here


Dynamic web applications also need static files, usually CSS and JavaScript files. Ideally, your server has been configured to serve your static files. But in the development process, Flask can also do this job well. Just create a folder named static next to your package or module. Static files are located in /static of the application.

Use a specific'static' endpoint to generate the corresponding URL

url_for('static', filename='style.css')
The location of this static file in the file system should be static/style.css

Guess you like

Origin blog.csdn.net/XRTONY/article/details/114818112