Skip to content

Instantly share code, notes, and snippets.

@santosh
Created November 2, 2017 07:50
Show Gist options
  • Save santosh/aca6b3e1afb574ef6aa39c64ff2c3146 to your computer and use it in GitHub Desktop.
Save santosh/aca6b3e1afb574ef6aa39c64ff2c3146 to your computer and use it in GitHub Desktop.
Render templates in Flask with Jinja2 template engine. #Flask #Python
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)
<p> Hello, cruel world! </p>
<h1>Hello, {{name}}!</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment