Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/api/server.py
Show First 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | def diff_revisions(): | ||||
return encode_data(get_storage().diff_revisions(**decode_request(request))) | return encode_data(get_storage().diff_revisions(**decode_request(request))) | ||||
@app.route('/algos/diff_revision', methods=['POST']) | @app.route('/algos/diff_revision', methods=['POST']) | ||||
def diff_revision(): | def diff_revision(): | ||||
return encode_data(get_storage().diff_revision(**decode_request(request))) | return encode_data(get_storage().diff_revision(**decode_request(request))) | ||||
api_cfg = None | |||||
def run_from_webserver(environ, start_response, | def run_from_webserver(environ, start_response, | ||||
config_path=DEFAULT_CONFIG_PATH): | config_path=DEFAULT_CONFIG_PATH): | ||||
"""Run the WSGI app from the webserver, loading the configuration.""" | """Run the WSGI app from the webserver, loading the configuration.""" | ||||
cfg = config.load_named_config(config_path, DEFAULT_CONFIG) | global api_cfg | ||||
app.config.update(cfg) | if not api_cfg: | ||||
api_cfg = config.load_named_config(config_path, DEFAULT_CONFIG) | |||||
ardumont: Not sure if there is a way to actually extract this in swh.core.
The default_config_path could… | |||||
app.config.update(api_cfg) | |||||
handler = logging.StreamHandler() | handler = logging.StreamHandler() | ||||
app.logger.addHandler(handler) | app.logger.addHandler(handler) | ||||
return app(environ, start_response) | return app(environ, start_response) | ||||
@click.command() | @click.command() | ||||
@click.argument('config-path', required=1) | @click.argument('config-path', required=1) | ||||
@click.option('--host', default='0.0.0.0', help="Host to run the server") | @click.option('--host', default='0.0.0.0', help="Host to run the server") | ||||
Show All 11 Lines |
Not sure if there is a way to actually extract this in swh.core.
The default_config_path could possibly go away (to remove yet again the implicit configuration).
The unsure stuff is about the global here.
My mind tells me to go check closure and global but not right now ;)