Created
November 2, 2017 07:50
-
-
Save santosh/aca6b3e1afb574ef6aa39c64ff2c3146 to your computer and use it in GitHub Desktop.
Render templates in Flask with Jinja2 template engine. #Flask #Python
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
from flask import Flask, request, make_response, redirect, \ | |
render_template | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return render_template('index.html') | |
@app.route('/user/<name>') | |
def user(name): | |
# note the name is a variable in user.html file | |
return render_template('user.html', name=name) | |
if __name__ == '__main__': | |
app.run(debug=True) |
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
<p> Hello, cruel world! </p> |
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
<h1>Hello, {{name}}!</h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment