def _make_standalone_handler(preamble):
"""Class factory used so that preamble can be passed to :py:class:`_StandaloneHandler`
without use of static members"""
class _StandaloneHandler(BaseHTTPRequestHandler, object):
"""HTTP Handler for standalone mode"""
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'application/json; charset=utf-8')
self.send_header('Content-length', len(preamble))
self.end_headers()
self.wfile.write(preamble.encode('utf-8'))
def log_message(self, format, *args):
# suppress logging on requests
return
return _StandaloneHandler
评论列表
文章目录