Merge pull request #130 from geopython/issue-129-cors

#129 #112 Move setting config options for CORS and JSONIFY to module level
This commit is contained in:
Just van den Broecke
2019-05-21 15:46:07 +02:00
committed by GitHub
+8 -7
View File
@@ -48,6 +48,14 @@ if 'PYGEOAPI_CONFIG' not in os.environ:
with open(os.environ.get('PYGEOAPI_CONFIG')) as fh:
CONFIG = yaml.load(fh)
# CORS: optionally enable from config.
if CONFIG['server'].get('cors', False):
from flask_cors import CORS
CORS(APP)
APP.config['JSONIFY_PRETTYPRINT_REGULAR'] = \
CONFIG['server'].get('pretty_print', True)
api_ = API(CONFIG)
@@ -156,13 +164,6 @@ def execute_process(name=None):
def serve(ctx, debug=False):
"""Serve pygeoapi via Flask"""
if not api_.config['server']['pretty_print']:
APP.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
if 'cors' in api_.config['server'] and api_.config['server']['cors']:
from flask_cors import CORS
CORS(APP)
# setup_logger(CONFIG['logging'])
APP.run(debug=True, host=api_.config['server']['bind']['host'],
port=api_.config['server']['bind']['port'])