import http.server, ssl, os, sys
os.chdir('/tmp/fonthost')
class H(http.server.SimpleHTTPRequestHandler):
    def log_message(self, fmt, *args):
        sys.stdout.write('%s - - [%s] %s\n' % (self.client_address[0], self.log_date_time_string(), fmt % args))
        sys.stdout.flush()
    def end_headers(self):
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()
    def do_POST(self):
        ln = int(self.headers.get('Content-Length') or 0)
        body = self.rfile.read(ln) if ln else b''
        sys.stdout.write('%s POST %s body=%s\n' % (self.client_address[0], self.path, body[:500]))
        sys.stdout.flush()
        self.send_response(200)
        self.send_header('Content-Type', 'text/plain')
        self.end_headers()
        self.wfile.write(b'ok')
httpd = http.server.ThreadingHTTPServer(('0.0.0.0', 443), H)
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ctx.load_cert_chain('/tmp/le/live/159.223.176.229.sslip.io/fullchain.pem', '/tmp/le/live/159.223.176.229.sslip.io/privkey.pem')
httpd.socket = ctx.wrap_socket(httpd.socket, server_side=True)
print('https payload server on 443', flush=True)
httpd.serve_forever()
