Commit defc3365 authored by John Wang's avatar John Wang

fix: uuid json dumps bug by set sqlalchemy version

parent b3186283
# -*- coding:utf-8 -*-
import os
import uuid
from datetime import datetime
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
......@@ -184,15 +183,6 @@ if app.config['TESTING']:
print("App is running in TESTING mode")
def uuid_encoder(self, obj):
if isinstance(obj, uuid.UUID):
return str(obj)
raise TypeError(f"Object of type '{type(obj)}' is not JSON serializable")
json.JSONEncoder.default = uuid_encoder
@app.after_request
def after_request(response):
"""Add Version headers to the response."""
......
import json
import uuid
from collections import defaultdict
from typing import Any, List, Optional, Dict
......@@ -236,6 +235,4 @@ class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
elif isinstance(obj, uuid.UUID):
return str(obj)
return super().default(obj)
......@@ -2,6 +2,7 @@ coverage~=7.2.4
beautifulsoup4==4.12.2
flask~=2.3.2
Flask-SQLAlchemy~=3.0.3
SQLAlchemy~=1.4.28
flask-login==0.6.2
flask-migrate~=4.0.4
flask-restful==0.3.9
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment