commit 3e06e914994968296e46aff2ec2709994d952639
Author: jimmy <me@jimmy.nz>
Date:   Fri Jul 5 11:06:15 2024 +0000

    Add lights.py

diff --git a/lights.py b/lights.py
new file mode 100644
index 0000000..aea2fbc
--- /dev/null
+++ b/lights.py
@@ -0,0 +1,37 @@
+import socket
+
+# Set up the server
+def start_server():
+    host = '0.0.0.0'  # Localhost
+    port = 80        # Port to listen on
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    s.bind((host, port))
+    s.listen(5)
+    print(f'Serving HTTP on {host} port {port} (http://{host}:{port}/) ...')
+
+    while True:
+        conn, addr = s.accept()
+        request = conn.recv(1024).decode('utf-8')
+        print(f'Connected by {addr}\nRequest:\n{request}')
+        
+        # Check if request is for the root path
+        if "GET /a " in request:
+            response = f'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\na'
+        elif "GET /b " in request:
+            response = f'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nb'
+        elif "GET /c " in request:
+            response = f'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nc'
+        elif "GET /d " in request:
+            response = f'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nd'
+        elif "GET /e " in request:
+            response = f'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\ne'
+        else:
+            response = 'HTTP/1.1 404 Not Found\r\n\r\n'
+
+        conn.sendall(response.encode('utf-8'))
+        conn.close()
+
+# Start the server
+if __name__ == '__main__':
+    start_server()
+