Created
October 19, 2018 08:43
-
-
Save redknitin/ab2cbea013c142ac037560c61cec5d7e to your computer and use it in GitHub Desktop.
Jinja template in Flask
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 Flask | |
from jinja2 import Environment, FileSystemLoader | |
j2_env = Environment(loader=FileSystemLoader('templates'), trim_blocks=True) | |
app = Flask(__name__) | |
@app.route('/') | |
def home(): | |
return j2_env.get_template('index.j2').render(name='Nitin') | |
def main(): | |
app.run(debug=True) | |
if __name__=='__main__': | |
main() |
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
{% extends "layout.j2" %} | |
{% block content %} | |
<p> | |
Hello {{name}} | |
</p> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment