From c71d13747236b865df81669973384dc53366d7ea Mon Sep 17 00:00:00 2001
From: raffitz <raf.a.m.c.gon@gmail.com>
Date: Tue, 15 Feb 2022 14:32:22 +0000
Subject: [PATCH] Add basic HTTP server

---
 server.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/server.py b/server.py
index 77163aa..6e4db3d 100755
--- a/server.py
+++ b/server.py
@@ -9,6 +9,22 @@ Functions:
 
 import ipaddress
 import argparse
+import http.server
+
+
+class HKPRequestHandler(http.server.BaseHTTPRequestHandler):
+    """HKP Request Handler Class"""
+
+
+def run_server(server_class=http.server.ThreadingHTTPServer,
+               handler_class=HKPRequestHandler,
+               ip_address='',
+               tcp_port=11371):
+    """Run HTTP server with HKP request handler"""
+    ip_address = str(ip_address)
+    server_address = (ip_address, tcp_port)
+    httpd = server_class(server_address, handler_class)
+    httpd.serve_forever()
 
 
 def port(val):
@@ -40,7 +56,7 @@ def main():
 
     args = parser.parse_args()
 
-    print(f'Server address parsed as {args.address}, port as {args.port}')
+    run_server(ip_address=args.address, tcp_port=args.port)
 
 
 if __name__ == '__main__':