Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/objstorage/api/server.py
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
@app.route('/content/check', methods=['POST']) | @app.route('/content/check', methods=['POST']) | ||||
def check(): | def check(): | ||||
return encode_data(g.objstorage.check(**decode_request(request))) | return encode_data(g.objstorage.check(**decode_request(request))) | ||||
@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") | ||||
@click.option('--port', default=5000, help="Server's port") | @click.option('--port', default=5000, type=click.INT, | ||||
help="Binding port of the server") | |||||
@click.option('--debug/--nodebug', default=True, | @click.option('--debug/--nodebug', default=True, | ||||
help="Indicates if the server should run in debug mode") | help="Indicates if the server should run in debug mode") | ||||
def launch(config_path, host, port, debug): | def launch(config_path, host, port, debug): | ||||
app.config.update(config.read(config_path, DEFAULT_CONFIG)) | app.config.update(config.read(config_path, DEFAULT_CONFIG)) | ||||
app.run(host, port=int(port), debug=bool(debug)) | app.run(host, port=int(port), debug=bool(debug)) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
launch() | launch() |