Encode datetime in JSON as ISO string
This commit is contained in:
parent
bd657d11b6
commit
0edd55b64e
|
@ -4,6 +4,8 @@
|
|||
Initialize also a singleton for the AccessTokenController and start the Thread.
|
||||
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
import yaml
|
||||
import logging
|
||||
import pkg_resources
|
||||
|
@ -33,6 +35,8 @@ class CustomJSONEncoder(JSONEncoder):
|
|||
except AttributeError:
|
||||
pass
|
||||
|
||||
if isinstance(o, datetime):
|
||||
return o.isoformat()
|
||||
# Check if iterable
|
||||
try:
|
||||
iterable = iter(o)
|
||||
|
@ -76,7 +80,7 @@ def create_app():
|
|||
def handle_exception(e):
|
||||
if isinstance(e, HTTPException):
|
||||
logger.debug(e.description, exc_info=True)
|
||||
return jsonify({"error": e.name}), e.code
|
||||
return jsonify({"error": e.description}), e.code
|
||||
|
||||
logger.error(str(e), exc_info=True)
|
||||
return jsonify({"error": "Internal server error occurred"}), 500
|
||||
|
|
Loading…
Reference in New Issue