title: Rendering Jinja template in Flask following ajax response
body: <p>This is my first dive into Flask + Jinja, but I've used HandlebarsJS a lot in the past, so I know this is possible but I'm not sure how to pull this off with Flask:</p>
  
  <p>I'm building an app: a user enters a string, which is processed via python script, and the result is ajax'd back to the client/Jinja template.</p>
  
  <p>I can output the result using $("body").append(response) but this would mean I need to write some nasty html within the append.</p>
  
  <p>Instead, I'd like to render another template once the result is processed, and append that new template in the original template.</p>
  
  <p>Is this possible?</p>
  
  <p>My python:</p>
  
  <pre><code>from flask import Flask, render_template, request, jsonify
  
  from script import *
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      return render_template('index.html')
  
  @app.route('/getColors')
  def add_colors():
  
      user = request.args.get("handle", 0, type = str)
  
      return jsonify(
          avatar_url = process_data(data)
      )
  
  if __name__ == '__main__':
      app.run()
  </code></pre>