Let data get expired.

This commit is contained in:
2021-06-20 12:19:35 +02:00
parent 29af01c619
commit f60e3a3f89
2 changed files with 14 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
from flask import Flask, abort, request, make_response
import json
import os
import time
app = Flask(__name__)
@@ -32,6 +33,7 @@ def ingress(key):
values[keys[key]] = {
"payload": request.data,
"content-type": content_type,
"last-modified": time.time(),
}
else:
return make_response("", 404)
@@ -42,10 +44,15 @@ def ingress(key):
def data(name):
if not name in config:
return make_response("", 404)
if name in values:
if "delete-after" in config[name]:
if (values[name]["last-modified"] + config[name]["delete-after"]) < time.time():
values.pop(name)
if not name in values:
return make_response("", 404)
resp = make_response(values[name]["payload"], 200)
resp.headers['content-type'] = values[name]["content-type"]
resp.headers['Content-Type'] = values[name]["content-type"]
resp.headers['Last-Modified'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(values[name]["last-modified"]))
return resp
if __name__ == "__main__":