Created
July 15, 2013 22:52
-
-
Save sloria/6004206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import render_template | |
from app import app, pages | |
@app.route('/') | |
def home(): | |
posts = [page for page in pages if 'date' in page.meta] | |
# Sort pages by date | |
sorted_posts = sorted(posts, reverse=True, | |
key=lambda page: page.meta['date']) | |
return render_template('index.html', pages=sorted_posts) | |
@app.route('/<path:path>/') | |
def page(path): | |
# `path` is the filename of a page, without the file extension | |
# e.g. "first-post" | |
page = pages.get_or_404(path) | |
return render_template('page.html', page=page) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment