How to interface JQuery with Flask?
<p>I'm writing a Google Chrome extension that uses a <code>jQuery.post()</code> call to send data to an external website.  The external website handles the data using a Flask endpoint and generates a result.  Unfortunately I am not sure how to transfer the result back to the client.  How can I do this?</p>

<p>I've tried using a <code>render_template</code> call within Flask, like so: </p>

<pre><code>app.route("/my_endpoint", methods = ['POST'])
def my_endpoint():
    print ('hi')  # this statement prints
    results = ...
    if request.method == 'POST':
        # want to eventually replace this with
        # return render_template("results.html", results=results)
        return render_template("test.html")
</code></pre>

<p>But this doesn't actually load the page <code>test.html</code>.</p>

<p>I've also tried transferring the data back to the Chrome extension using a callback (which I would prefer not to do if possible), as in</p>

<pre><code>post_results = function(input_data) {
    jQuery.post("my_flask_endpoint",
        input_data,
        function (data, textStatus, jqXHR) {
            ...
        }
</code></pre>

<p>But I'm not sure what to put in the callback function, because it seems like "data" is a bunch of HTML, and I don't know how to load pages given only an HTML string (as opposed to the URL).</p>