title: How to return a javascript output back to a python's http requests using flask
body: <p>I want to create a flask app that processes a video file that the users send through python HTTP request and return the resulting value back. my problem is that I need to use a javascript library and I don't know how to return the javascript results back to the flask app. </p>
  
  <p>I embed the image into template.html which runs my javascript file. The problem is I don't know how to return this variable back to the POST request. Is this even doable? And if not what is the best way to pass javascript result back to flask. </p>
  
  <p>python call</p>
  
  <pre><code>r = requests.post('URLForFlaskServer/processFile', files=files,)
  </code></pre>
  
  <p>flask app</p>
  
  <pre><code>@app.route('/processFile', methods=['POST'])
  def process_file():
      file = request.files['image_file']
      f = os.path.join(app.config['UPLOAD_FOLDER'], "videoFile.mp4")
      file.save(f)
      render_template('template.html', filename=f)
      return  #not sure how to return "result" from processFunc.js
  </code></pre>
  
  <p>template.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script type="text/javascript" src="{{ url_for('static', filename='processFunc.js') }}"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;video id="video" style="display:none"&gt;&lt;source src={{url_for('static', filename='videoFile.mp4')}} type="video/mp4"&gt;&lt;/video&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>processFunc.js</p>
  
  <pre><code>$(window).load(function(){
   (function() { 
        someProcess = function(vid){...}
        result = someProcess(document.getElementById('video'));
    })();
  });
  </code></pre>