Created
December 11, 2012 05:26
-
-
Save rjurney/4256114 to your computer and use it in GitHub Desktop.
How do I do this splatization in Flask without being SO FREAKING UGLY?
This file contains hidden or 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
# Enable /emails and /emails/ to serve the last 20 emaildb in our inbox unless otherwise specified | |
default_offsets={'offset1': 0, 'offset2': 0 + config.EMAIL_RANGE} | |
@app.route('/', defaults=default_offsets) | |
@app.route('/emails', defaults=default_offsets) | |
@app.route('/emails/', defaults=default_offsets) | |
@app.route("/emails/<int:offset1>/<int:offset2>") | |
def list_emaildb(offset1, offset2): | |
offset1 = int(offset1) | |
offset2 = int(offset2) | |
emails = emaildb.find()[offset1:offset2] # Uses a MongoDB cursor | |
nav_offsets = get_offsets(offset1, offset2, config.EMAIL_RANGE) | |
data = {'emails': emails, 'nav_offsets': nav_offsets, 'nav_path': '/emails/'} | |
return render_template('partials/emails.html', data=data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment