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