Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flask Jinja template

  • jinja

  • render_template

  • Jinja

from flask import Flask, request, render_template
app = Flask(__name__)

@app.route("/")
def main():
    return render_template('index.html')

@app.route("/echo", methods=['POST'])
def echo():
    user_text = request.form.get('text', '')
    return "You said: " + user_text
<form action="/echo" method="POST">
<input name="text">
<input type="submit" value="Echo">
</form>