mirror of
https://github.com/stijndcl/didier.git
synced 2026-06-29 17:39:57 +02:00
Command stats
This commit is contained in:
parent
ce9ecc8c61
commit
41f75d7bbd
4 changed files with 47 additions and 45 deletions
15
backend/json_encoder.py
Normal file
15
backend/json_encoder.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from datetime import date
|
||||
|
||||
from quart.json import JSONEncoder
|
||||
|
||||
|
||||
class CustomEncoder(JSONEncoder):
|
||||
"""
|
||||
Custom JSON encoder to handle things like date parsing
|
||||
"""
|
||||
def default(self, o):
|
||||
# Return dates as ISO strings
|
||||
if isinstance(o, date):
|
||||
return o.isoformat()
|
||||
|
||||
return super().default(o)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from werkzeug.exceptions import abort
|
||||
|
||||
from .error_handlers import handler_404, handler_422
|
||||
from .json_encoder import CustomEncoder
|
||||
from .routes.dm import dm_blueprint
|
||||
from .routes.ping import ping_blueprint
|
||||
from .routes.stats import stats_blueprint
|
||||
|
|
@ -15,6 +16,7 @@ app = Quart(__name__)
|
|||
# needs higher Python & Quart version
|
||||
app = cors(app, allow_origin="*")
|
||||
app.url_map.strict_slashes = False
|
||||
app.json_encoder = CustomEncoder
|
||||
|
||||
# Register blueprints
|
||||
app.register_blueprint(dm_blueprint)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue