title: Python Tornado rest API calls not rendering to mobile
body: <p>API results render to desktop but not to my iPhone. So I have a simple rest API that I'm making the calls from a ReactJS front end. I'm using axios after having a LOT of troubles with superagent. I'm not getting any errors in any browser console, desktop or mobile(been using jsconsole to debug my iphone 5). Yet on my Python Tornado back end it's throwing a few errors for both desktop and mobile:</p>
  
  <p>1st: </p>
  
  <blockquote>
    <p>tornado.application:Uncaught exception GET</p>
  </blockquote>
  
  <p>2nd:</p>
  
  <blockquote>
    <p>ERROR:tornado.general:Cannot send error response after headers written
    ERROR:tornado.general:Failed to flush partial response</p>
  </blockquote>
  
  <p>3rd:</p>
  
  <blockquote>
    <p>During handling of the above exception, another exception occurred:</p>
  </blockquote>
  
  <p>and this can be found as the error happening in my Python env files</p>
  
  <blockquote>
    <p>TypeError: 'str' object is not callable</p>
  </blockquote>
  
  <p>none of this crashes the script/app... Here's my ReactJS/Javascript using axios:</p>
  
  <pre><code>componentDidMount() {
      console.log('componentDidMount');
  
      const url = 'http://127.0.0.1:3000/api/generator';
      axios.get(url).then((response) =&gt; {
          const results = response.data
          console.log(JSON.stringify(results.data))
          this.setState({data: results.powergen})
      })
  }
  
  render() {
      const powergenName = this.state.data.map((powergen, i) =&gt; {
          const pgBrand = new RegExp(this.state.brandSelected)
          console.log(this.state.brandSelected)
          if (pgBrand.test(powergen.name)) {
              return &lt;div className="row" key={i}&gt;&lt;br/&gt;
                  &lt;Card style={{
                      width: '250px'
                  }}&gt;
                      &lt;CardTitle title={powergen.price} subtitle={powergen.model}/&gt;
                      &lt;CardTitle title={powergen.name} subtitle={powergen.deal}/&gt;
                  &lt;/Card&gt;
              &lt;/div&gt;
          } else
              return false
      })
      return (
          &lt;div&gt;
              &lt;Dropdown source={this.brands} onChange={this.handleBrandChange} value={this.state.brandSelected}/&gt;
              &lt;div&gt;{powergenName}&lt;/div&gt;
          &lt;/div&gt;
      )
  }
  </code></pre>
  
  <p>and here's my Python Tornado bit:</p>
  
  <pre><code>class PowgenHandler(tornado.web.RequestHandler):
  
  def send_error(self, status_code=500, **kwargs):
      """
      Generates the custom HTTP error.And always return 200 code.
      """
      reason = None
      if 'exc_info' in kwargs:
          exception = kwargs['exc_info'][1]
          if isinstance(exception, HTTPError) and exception.reason:
              reason = exception.reason
      try:
          msg = reason if reason else httputil.responses[status_code]
      except KeyError:
          msg = "unkown error"
  
      result = {"status_code":status_code, "reason": msg}
  
      self.clear()
      self.set_header("Content-Type", "application/json")
      self.set_status(200)
      self.write(tornado.escape.json_encode(result))
      self.finish()
  
  def set_default_headers(self):
      print("setting headers!!!")
      self.set_header("Access-Control-Allow-Origin", '*')
      self.set_header("Access-Control-Allow-Headers", 'Content-Type')
      self.set_header('Access-Control-Allow-Methods', 'GET')
      self.set_header('Access-Control-Allow-Credentials', 'None')
  
  async def get(self):
      output = []
      gn = db.generators.find()
      for gens in (await gn.to_list(length=1000)):
          output.append({'name': gens['name'],
                         'model': gens['model'],
                         'price': gens['price'],
                         'deal': gens['deal'],
                         'image': gens['image'],
                         'id': gens['gen_id']})
      self.write(json.dumps({'powergen': output}))
      self.finish()
  </code></pre>
  
  <p>It's pretty straight forward so I'm not getting why it's not working on my iPhone. I guess I should also mention that I'm using Motor for MongoDB async which is why that async &amp; await are there. Other than that, I did remove all the styling &amp; react-toolbox stuff just to make sure it wasn't rendering because of that and it didn't make a difference.</p>
  
  <p>I know there's something maybe a bunch of things I'm not doing but I can't figure out what that is as Google searching any of the errors only comes back with less than 5 relevant results. Any input would be greatly appreciated. Thanks!</p>
  
  <p>oh - here's a link to my GitHub repo for it if you want/need to see the entire project. Thanks again! <a href="https://github.com/ideletemyself/Tornado-Pricer" rel="nofollow noreferrer">Tornado-Pricer</a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is what I get in my console:
  <a href="https://i.stack.imgur.com/PMwoc.png" rel="nofollow noreferrer">Python Tornado errors</a></p>