title: Posting from php to Flask
body: <p><img src="https://i.stack.imgur.com/fm6mM.png" alt="enter image description here"></p>
  
  <p>I have a php app which posts variable info to a flask app (which does some calculations and returns a result ). I'm running both locally on win7 </p>
  
  <p>When I test the url "127.0.0.1:5000/index" using a post with postman, I get a 200 status code (screenshot). However when the php app posts to the flask app I get:</p>
  
  <pre><code>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
  </code></pre>
  
  <p>I'm using CURL , and the verbose output is:</p>
  
  <pre><code>* About to connect() to 127.0.0.1 port 5000 (#0)
  *   Trying 127.0.0.1...
  * connected
  * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
  &gt; POST /index/ HTTP/1.1
  User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
  Host: 127.0.0.1:5000
  Accept: */*
  Content-Length: 338
  Expect: 100-continue
  Content-Type: multipart/form-data; boundary=----------------------------d5cb02e2edea
  &lt; HTTP/1.1 100 Continue
  * HTTP 1.0, assume close after body
  &lt; HTTP/1.0 404 NOT FOUND
  &lt; Content-Type: text/html
  &lt; Content-Length: 233
  &lt; Server: Werkzeug/0.10.4 Python/2.7.5
  </code></pre>
  
  <p>My php code looks like:</p>
  
  <pre><code>   $data= array('a'=&gt;$a, 'token'=&gt;$token);
     $url="http://127.0.0.1:5000/index/";
     $output = $this-&gt;my_model-&gt;get_data($url, $data);
  
  public function get_data($url,$postFieldArray=FALSE) {
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  if ($postFieldArray!= FALSE) {
      curl_setopt($ch, CURLOPT_POST, TRUE);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $postFieldArray); //for django
  }
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  curl_setopt($ch, CURLOPT_STDERR, $verbose);
  curl_setopt($ch, CURLOPT_URL, $url);
  $html = curl_exec($ch);
  curl_close($ch);
  .......
  
  return $result;
  }
  </code></pre>
  
  <p>Simplified Flask app:</p>
  
  <pre><code>app = Flask(__name__)
  app.debug = True
  
  @app.route('/')
  def hello_world():
      return 'Hello World!'
  
  @app.route('/index',methods=['POST'])
  def index():
  
      token = request.form['token']
      a = request.form['a']
      ......
      return
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>What am I doing wrong?</p>