#!/usr/bin/env python3
from http.server import HTTPServer, CGIHTTPRequestHandler
+import random
class SimpleHTTPRequestHandler(CGIHTTPRequestHandler):
def do_GET(self):
self.end_headers()
self.wfile.write(b'Hello, world!')
+ def do_PUT(self):
+ if bool(random.getrandbits(1)):
+ self.send_response(200)
+ else:
+ self.send_response(201)
+ self.end_headers()
+ self.wfile.write(b'Hello, world!')
+
httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
httpd.serve_forever()