#!/usr/bin/env python3

import signal
import sys

from urllib.parse import unquote
from http.server import BaseHTTPRequestHandler, HTTPServer


def signal_handler(sig, frame):
    print('Servidor detenido...')
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)


class RequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        decoded_path = unquote(self.path[1:])
        print(decoded_path)
        self.send_response(200)
        self.end_headers()


if __name__ == '__main__':
    server_address = ('', 80)
    httpd = HTTPServer(server_address, RequestHandler)
    print('Servidor iniciado en el puerto 80...')
    httpd.serve_forever()
