title: How to write Locust result of test api to file
body: <p>I invoke the test through API,</p>
  
  <pre><code>locust -f locustfile.py --host=http://localhost --no-web  --hatch-rate=20 --clients=10000
  </code></pre>
  
  <p>and got a result</p>
  
  <pre><code> Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s
  --------------------------------------------------------------------------------------------------------------------------------------------
   POST 8000/queries.json                                           137     0(0.00%)       5       2      23  |       5   11.00
  
  --------------------------------------------------------------------------------------------------------------------------------------------
   Total                                                            708     0(0.00%)    
  </code></pre>
  
  <p>I would like to write this result to a file. Can anyone help me with this?</p>
  
  <p>Below is the code in python</p>
  
  <pre><code>@task(1)
  def test_topview(self):
      post_data_topview = """{ "category": "321",   "num": 20,   "genderCat" : ["23"] }"""
      with self.client.request(method="POST", url="http://192.168.1.107:8001/queries.json", headers= {"Content-Type" : "application/json"}, data = post_data_topview, catch_response = True ) as response:
          if not matched(response.content) :
              response.failure("No content")
  </code></pre>
  
  <p>Thank you very much.</p>