2626
2727
2828class AWFlask (Flask ):
29- def __init__ (self , name , * args , ** kwargs ):
29+ def __init__ (self , name , testing : bool , * args , ** kwargs ):
30+ self .json_provider_class = rest .CustomJSONProvider
31+
32+ # Only pretty-print JSON if in testing mode (because of performance)
33+ self .json_provider_class .compact = not testing
34+
35+ # Initialize Flask
3036 Flask .__init__ (self , name , * args , ** kwargs )
3137
3238 # Is set on later initialization
@@ -36,23 +42,17 @@ def __init__(self, name, *args, **kwargs):
3642def create_app (
3743 host : str , testing = True , storage_method = None , cors_origins = [], custom_static = dict ()
3844) -> AWFlask :
39- app = AWFlask ("aw-server" , static_folder = static_folder , static_url_path = "" )
40-
41- if storage_method is None :
42- storage_method = aw_datastore .get_storage_methods ()["memory" ]
43-
44- # Only pretty-print JSON if in testing mode (because of performance)
45- app .config ["JSONIFY_PRETTYPRINT_REGULAR" ] = testing
45+ app = AWFlask ("aw-server" , testing , static_folder = static_folder , static_url_path = "" )
4646
4747 with app .app_context ():
4848 _config_cors (cors_origins , testing )
4949
50- app .json_encoder = rest .CustomJSONEncoder
51-
5250 app .register_blueprint (root )
5351 app .register_blueprint (rest .blueprint )
5452 app .register_blueprint (get_custom_static_blueprint (custom_static ))
5553
54+ if storage_method is None :
55+ storage_method = aw_datastore .get_storage_methods ()["memory" ]
5656 db = Datastore (storage_method , testing = testing )
5757 app .api = ServerAPI (db = db , testing = testing )
5858
0 commit comments