Some final Flask notes

A summary of Flask things covered in class today.

flask_routes

The above comes from this page. In case you want to set a default for a Flask route, or in case you want to have two possibilities open the same URL.

Also remember, we discovered last week that @app.route('/members/') works better than @app.route('/members') — the use of two slashes is more flexible for what people might do in the browser’s address bar.

We discussed Flask’s extra-special static folder. This must be on the same level (at the project’s root) with the templates folder. When you write a link or src attribute to get a file from the static folder, it will follow one of these patterns:

src="{{ url_for( 'static', filename='images/donkey.jpg' }}"

src="/static/images/donkey.jpg"
src="/static/images/{{ number }}.jpg"

href="/static/pages/donkey.html"

src="/static/scripts/donkey.js"
href="/static/styles/donkey.css"

If you have any additional Flask questions or Flask tips, please add them in the comments here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s