示例#1
0
def api_(config):
    return API(config)
示例#2
0
if 'PYGEOAPI_CONFIG' not in os.environ:
    raise RuntimeError('PYGEOAPI_CONFIG environment variable not set')

with open(os.environ.get('PYGEOAPI_CONFIG')) as fh:
    CONFIG = yaml.load(fh, Loader=yaml.FullLoader)

# 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)


@APP.route('/')
def root():
    headers, status_code, content = api_.root(request.headers, request.args)

    response = make_response(content, status_code)
    if headers:
        response.headers = headers

    return response


@APP.route('/api')
def api():