diff --git a/server.py b/server.py index 8f2810c..8a7fd79 100644 --- a/server.py +++ b/server.py @@ -15,7 +15,7 @@ class Collector: def __init__(self) -> None: self.secrets = os.getenv("KEYS", "secret").split(",") self.hosts = os.getenv("HOSTS", "srv").split(",") - self.dead_after = int(os.getenv("DEAD_AFTER", "60")) + self.dead_after = int(os.getenv("DEAD_AFTER", "90")) self.build_routes() def check_headers(self, request: Request): @@ -55,7 +55,10 @@ class Collector: host = host.split(":")[0] if host in self.store and self.store[host]['data']: - return Response(content=self.store[host]['data'], status_code=200) + return Response( + content=self.store[host]['data'], + status_code=200, + headers=self.store[host]['headers']) else: return Response(status_code=404) @@ -70,8 +73,11 @@ class Collector: self.store[host] = { "data":await request.body(), - "timestamp": time() + "timestamp": time(), + "headers": { + "Content-Type": "text/plain; version=0.0.4; charset=utf-8; escaping=underscores" } + } background_tasks.add_task(self.deadline, host) return Response(status_code=200)