Flask application


In this simple Flask web application we have 3 files. app.py, a template, and the requirements.txt

examples/flask-development/app.py
from flask import Flask, request, render_template
app = Flask(__name__)

@app.route("/")
def hello():
    return render_template('echo.html')

@app.route("/echo", methods=['POST'])
def echo():
    return render_template('echo.html', text=request.form['text'])

examples/flask-development/templates/echo.html
<form action="/echo" method="POST">
<input name="text">
<input type="submit" value="Echo">
</form>

{% if text %}
  You said: {{ text }}
{% endif %}

examples/flask-development/requirements.txt
flask
pytest