title: How to send a string on Python Flask route to a JS function?
body: <p>This is the route on <code>app.py</code></p>
  <pre><code>app.route('/analyze', methods=['POST'])
  async def analyze(requestArg):
      img_data = await requestArg.form()
      img_bytes = await (img_data['file'].read())
      img = open_image(BytesIO(img_bytes))
      prediction = learn.predict(img)[0]
      result(str(prediction))
  </code></pre>
  <p>I'm trying to send the <code>str(prediction)</code> to the <code>result()</code> function on <code>static/js/script.js</code> here</p>
  <pre><code>function result(str) {
      $(&quot;.pd-result&quot;).show();
  
      var resultText = $(&quot;.text&quot;)
      switch (str) {
          case &quot;emotion&quot;:
              text.html(&quot;angry&quot;);
              break;
  
          default:
              break;
      }
  };
  </code></pre>
  <p>I've tried to just directly call <code>result(str(prediction))</code> but it doesn't work.</p>