title: How to catch response of server in mitmproxy container and past it into file in json format?
body: <p>I need to catch and fill in separated file every response,request which is going through my mitmproxy container. </p>
  
  <h1>Dockerfile</h1>
  
  <pre><code>FROM mitmproxy/mitmproxy:latest
  
  RUN mkdir url_catching
  WORKDIR /home/$USER/url_catching
  COPY ./url.py .
  
  
  
  EXPOSE 8080:8080
  
  ENTRYPOINT ["/usr/bin/mitmdump","-s","./url.py"]
  </code></pre>
  
  <h1>Docker run</h1>
  
  <pre class="lang-sh prettyprint-override"><code>sudo docker run --rm -it -p 8080:8080 mitmdump_url:latest
  </code></pre>
  
  <h1>My pyhton script(sry, i am novice in python)</h1>
  
  <pre class="lang-py prettyprint-override"><code>from mitmproxy import http
  
  def response(flow):
      url_request: str = str(flow.request.pretty_url)
      url_request = url_request.replace("/", "_")
      with open(url_request, "ab") as ofile:
          ofile.write(flow.request.pretty_url.encode())
          ofile.write(flow.request.content)
          ofile.write(flow.response.content)
  
  </code></pre>
  
  <ul>
  <li>in the result i get separated files for each request and name of it is equal to url of request, but only url is in human readable format everything else is encoded or just missed.
  So i need to past response which is going through my proxy in json format to files.</li>
  </ul>