from http.server import BaseHTTPRequestHandler, HTTPServer class RequestHandler(BaseHTTPRequestHandler): def do_GET(self): # Get the current requested URL current_url = self.path # Set the response status code self.send_response(200) # Set the response headers self.send_header('Content-type', 'text/html') self.end_headers() # Create the HTML page with the current URL html = f"""
{current_url}
""" # Send the HTML response to the client self.wfile.write(html.encode('utf-8')) def run_server(port=7000): server_address = ('', port) httpd = HTTPServer(server_address, RequestHandler) print(f'Starting server on port {port}...') httpd.serve_forever() if __name__ == '__main__': run_server()