(self, data:bytes, content_type:str="application/json", status_code:int=200)
| 21 | |
| 22 | class HTTPRequestHandler(BaseHTTPRequestHandler): |
| 23 | def send_data(self, data:bytes, content_type:str="application/json", status_code:int=200): |
| 24 | self.send_response(status_code) |
| 25 | self.send_header("Content-Type", content_type) |
| 26 | self.send_header("Content-Length", str(len(data))) |
| 27 | self.end_headers() |
| 28 | return self.wfile.write(data) |
| 29 | def stream_json(self, source:Generator): |
| 30 | try: |
| 31 | self.send_response(200) |