Created
November 10, 2014 23:35
-
-
Save jmcelroy5/b27455eeb8ae0c94e46c to your computer and use it in GitHub Desktop.
Flask function + Jinja template
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
// Flask function: | |
@app.route("/") | |
def home_page(): | |
# Get first 10 bikes from database | |
bikes = model.session.query(model.Bike).limit(10).all() | |
return render_template("index.html", bikes=bikes) | |
// In Jinja template: | |
{% extends 'base.html' %} | |
{% block content %} | |
<div> | |
{% for bike in bikes %} | |
<p> Why isn't this block showing?! </p> | |
<h3> {{ bike.title }} <h3> | |
<img src="{{ bike.thumb }}"> | |
{% endfor %} | |
</div> | |
<br> | |
<div> | |
<p> This block IS showing up </p> | |
<p> map with listing markers will go here<p> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment