Book Image

Learning Flask Framework

Book Image

Learning Flask Framework

Overview of this book

Table of Contents (17 chapters)
Learning Flask Framework
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Serving static files


Flask will automatically serve up files from our /static/ directory. When we deploy our site in Chapter 10, Deploying Your Application, we will use the Nginx web server to serve static assets but, for local development, Flask makes things really easy.

In addition to our image uploads, let's also serve our site's JavaScript and stylesheets from /static/. Download jQuery and Bootstrap and place the JavaScript files (jquery-<version>.min.js and boostrap.min.js) in static/js. Place the minified bootstrap CSS file (bootstrap.min.css) in static/css. Bootstrap also comes with some special fonts that are used for icons. Copy the bootstrap fonts directory into the static directory as well. You should now have four directories inside your application's static directory: css, fonts, images and js, each containing the relevant files:

(blog) $ cd static/ && find . -type f
./fonts/glyphicons-halflings-regular.woff
./fonts/glyphicons-halflings-regular.ttf
./fonts/glyphicons...