How to show confirmation modal in Flask app after form submission?
<p>I'm trying to show a confirmation/success message to the user in my Flask app, but I can't figure out how to display it in a modal.</p>

<pre><code>@app.route("/", methods=["POST"]
def sendForm():
    form = ContactForm(request.form)
    if request.method == 'POST':
        if form.validate():
            # do stuff with form data
            return render_template("contact.html", form=form)
        else:
            # display error message
    else:
        return render_template("index.html")
</code></pre>

<p>The part where I return the <code>contact.html</code> template is where I need help, I think. Because that page is basically refreshed and shown again after the POST request successfully completes. Need to display a confirm message to the user in a modal instead.</p>

<p>On the front-end, my form is looks like this:</p>

<pre><code>&lt;form method="POST" action="{{ url_for('sendForm') }}"&gt;
    &lt;input type="hidden" name="csrf_token" value="{{ csrf_token() }}" /&gt;
    {{ render_field(form.email) }}
    {{ render_field(form.name) }}
    &lt;input id="submit-form" type="submit" value="Send"&gt;
&lt;/form&gt;
</code></pre>