title: Use Flask to run a python script using javascript
body: <p>I want to run a python script using javascript. </p>
  
  <p>I installed Flask.</p>
  
  <p>this is my html code : </p>
  
  <pre><code>&lt;input type="button" value="tester" onclick="addImage()" /&gt;
  
  &lt;p id="result"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  function callPy(data1, data2){
      $.ajax({
          type: "POST",
          url:"/test",
          data:{data1: data1, data2:data2},
          success:callbackFunc
      });
  
  function callbackFunc(response) {
      $('#result').html('&lt;li&gt;'+response.x+'&lt;/li&gt;');
  }
  function addImage(){
      callPy(1,2);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And this is my python code : </p>
  
  <pre><code>  import csv
  from numpy import genfromtxt
  from numpy import matrix
  
  from flask import Flask, render_template, redirect, url_for,request
  from flask import make_response
  app = Flask(__name__)
  
  @app.route('/test', method='POST')
  def test():
      if request.method == 'POST'
      data1 = request.form['data1']
      data2 = request.form['data2']
      return "ok""
      return render_template('watermark.html', message='azerty')
  
  
  if __name__ == "__main__":
      app.run(debug = True)
  </code></pre>
  
  <p>But I have this error in the console :  <code>jquery.min.js:5 POST http://testFalsk/test 404 (Not Found)</code>
  What I have to make?</p>