This commit is contained in:
Wolfgang Hottgenroth 2021-05-05 18:27:26 +02:00
parent c98243d39b
commit 6344a19ad1
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469

View File

@ -1,19 +1,24 @@
import _typeshed
import logging
import werkzeug
from flask import request
from flask import request, Response
import json
class Entry(object):
def __init__(self, ts, freq):
self.ts = ts
self.freq = freq
def __init__(self, d):
self.ts = d['timestamp']
self.freq = d['frequency']
def __repr__(self):
return self.__str__()
def __str__(self):
return "<ts:{}, f:{}>".format(self.ts, self.freq)
def insert(**args):
try:
body = request.json
logging.info("JSON Body: {}".format(body))
return "200"
entryListJSON = request.json
logging.info("JSON Body: {}".format(entryListJSON))
entryList = [ Entry(x) for x in entryListJSON ]
logging.info("EntryList: {}".format(entryList))
return Response("", status=201)
except KeyError as e:
raise werkzeug.exceptions.InternalServerError("Key Error: {}".format(e))