#!/usr/bin/python3
import http.server
import socket
import socketserver
from http.server import HTTPServer, BaseHTTPRequestHandler

PORT = 8000

class Request(BaseHTTPRequestHandler):
    def do_GET(self):
        code = int(self.path.split("/")[1])
        
        self.send_response(code)
        self.send_header('Content-type', 'text/plain')
        self.end_headers()

class HTTPServer(socketserver.TCPServer):
    def server_bind(self):
        self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.socket.bind(self.server_address)

Handler = http.server.SimpleHTTPRequestHandler
with HTTPServer(("", PORT), Request) as httpd:
    httpd.serve_forever()
