MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / serve_image

Method serve_image

utils.py:379–395  ·  view source on GitHub ↗
(self, handler)

Source from the content-addressed store, hash-verified

377 handler.wfile.write(json.dumps(self.shared_data.config).encode('utf-8'))
378
379 def serve_image(self, handler):
380 image_path = os.path.join(self.shared_data.webdir, 'screen.png')
381 try:
382 with open(image_path, 'rb') as file:
383 handler.send_response(200)
384 handler.send_header("Content-type", "image/png")
385 handler.send_header("Cache-Control", "max-age=0, must-revalidate")
386 handler.end_headers()
387 handler.wfile.write(file.read())
388 except FileNotFoundError:
389 handler.send_response(404)
390 handler.end_headers()
391 except BrokenPipeError:
392 # Ignore broken pipe errors
393 pass
394 except Exception as e:
395 self.logger.error(f"Unexpected error: {e}")
396
397
398 def serve_favicon(self, handler):

Callers

nothing calls this directly

Calls 3

errorMethod · 0.80
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected