Showing demo step by step with flask

Solution
index :int
# I decided to put the steps as a global list, so that it doesn't assign it to the variable
# each time that demo() and step_by_step() are called, and so that I don't need to pass as argument
demo_steps = [...]

# demo just calls step_by_step(), but it always starts from 0
# So when user clicks on "demo" in navigator link, the demo restarts
@app.route('/demo')
def demo():
    global index
    index = 0
    return redirect(url_for('step_by_step', step=index))
    step_by_step(index)

@app.route('/demo/', methods = ["GET", "POST"])
def step_by_step(step):
    global index, demo_steps
    index = min(step, len(demo_steps)-1)  # to prevent a user from typing "/demo/20" (for example) in the URL
    short_answer = demo_steps[index][0]
    detailed_answer = demo_steps[index][1]

    if request.method == "POST":
        if 'yes' in request.form:
            return render_template('demo.html',
                                   short = short_answer,
                                   detailed = detailed_answer,
                                   show_answer = True)
        # user clicked 'no' ( = doesn't want detailed explanation),
        # or 'next' (after seeing the detailed explanation)
        # Either way, we move to the next step in the demo
        elif 'no' or 'next' in request.form:
            index += 1
            if index < len(demo_steps):
                return redirect(url_for('step_by_step', step=index))
                step_by_step(index)
            else:
                return redirect(url_for('finished'))
    elif request.method == "GET":
        return render_template('demo.html',
                   short = short_answer,
                   detailed = detailed_answer,
                   show_answer = False)

@app.route('/finished')
def finished():
    return render_template('finished.html') # A simple page saying demo is finished

The short answer is: {{ short }}

Do you want to see how the answer was reached?

{% if show_answer %}

These are the steps that the program took to find the answer

{% for step in detailed %}
  • {{ step }}
  • {% endfor %}

    {% endif %}