title: Reading POST body with bottle.py
body: <p>I am having trouble reading a POST request with <code>bottle.py</code>.</p>
  
  <p>The request sent has some text in its body. You can see how it's made here on line 29: <a href="https://github.com/kinetica/tries-on.js/blob/master/lib/game.js" rel="noreferrer">https://github.com/kinetica/tries-on.js/blob/master/lib/game.js</a>.</p>
  
  <p>You can also see how it's read on a <code>node</code>-based client here on line 4: <a href="https://github.com/kinetica/tries-on.js/blob/master/masterClient.js" rel="noreferrer">https://github.com/kinetica/tries-on.js/blob/master/masterClient.js</a>.</p>
  
  <p>However, I haven't been able to mimic this behavior on my <code>bottle.py</code>-based client. The <a href="http://bottlepy.org/docs/0.11/api.html#bottle.BaseRequest.body" rel="noreferrer">docs</a> say that I can read the raw body with a file-like object, but I can't get the data neither using a for loop on <code>request.body</code>, nor using <code>request.body</code>'s <code>readlines</code> method.</p>
  
  <p>I'm handling the request in a function decorated with <code>@route('/', method='POST')</code>, and requests arrive correctly.</p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>The complete script is:</p>
  
  <pre><code>from bottle import route, run, request
  
  @route('/', method='POST')
  def index():
      for l in request.body:
          print l
      print request.body.readlines()
  
  run(host='localhost', port=8080, debug=True)
  </code></pre>