From 54960ee284b4d740b41c82384c4c3bfa06e71cee Mon Sep 17 00:00:00 2001 From: Drew Short Date: Wed, 4 Jul 2018 12:42:26 -0500 Subject: [PATCH] Adding missing files --- server/atheneum/utility.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 server/atheneum/utility.py diff --git a/server/atheneum/utility.py b/server/atheneum/utility.py new file mode 100644 index 0000000..53f8abd --- /dev/null +++ b/server/atheneum/utility.py @@ -0,0 +1,17 @@ +from datetime import date + +import rfc3339 +from flask.json import JSONEncoder + + +class CustomJSONEncoder(JSONEncoder): + def default(self, obj): + try: + if isinstance(obj, date): + return rfc3339.format(obj) + iterable = iter(obj) + except TypeError: + pass + else: + return list(iterable) + return JSONEncoder.default(self, obj)