Archived
Remove CustomJSONEncoder
This commit is contained in:
1 parent
6b0d5df885
commit
91bc493153
2 files changed
+2
-18
No files matched your search
+2
-3
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import Flask, request, g, abort, jsonify
|
||||
from utils import CustomJSONEncoder, generate_activation_code
|
||||
from flask import Flask, request, g, abort
|
||||
from utils import generate_activation_code
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
import datetime
|
||||
@@ -13,7 +13,6 @@ import config
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config')
|
||||
app.json_encoder = CustomJSONEncoder
|
||||
|
||||
if not app.debug:
|
||||
import logging
|
||||
|
||||
@@ -1,22 +1,7 @@
|
||||
from datetime import date
|
||||
from flask.json import JSONEncoder
|
||||
import string
|
||||
import random
|
||||
|
||||
|
||||
class CustomJSONEncoder(JSONEncoder):
|
||||
def default(self, obj):
|
||||
try:
|
||||
if isinstance(obj, date):
|
||||
return obj.isoformat()
|
||||
iterable = iter(obj)
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
return list(iterable)
|
||||
return JSONEncoder.default(self, obj)
|
||||
|
||||
|
||||
def generate_activation_code(length=5):
|
||||
chars = string.ascii_lowercase + string.digits
|
||||
# remove easily misinterpreted chars
|
||||
|
||||
Reference in new issue
Block a user