From 9fbd23861b50603f20f005dfc79d903fdbfbb3e0 Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Thu, 20 May 2021 13:11:42 +0200 Subject: [PATCH] fileserver response headers --- fileserver.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fileserver.py b/fileserver.py index 51964bd..109616f 100755 --- a/fileserver.py +++ b/fileserver.py @@ -34,8 +34,16 @@ class FileServerRequestHandler(BaseHTTPRequestHandler): path = self.server.cleanPath(self.path) if path in self.server.routes: - data, code = self.server.routes[path](self) - self.send_response(code) + result = self.server.routes[path](self) + status_code = 200 if len(result) < 1 else result[0] + data = b"" if len(result) < 2 else result[1] + headers = { } if len(result) < 3 else result[2] + + self.send_response(status_code) + + for key, value in headers.items(): + self.send_header(key, value) + self.end_headers() if data and self.command != "HEAD":