From caaefdaa93aec7e4998b5f6ce5c974519af533f2 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 10 May 2022 16:35:01 -0400 Subject: [PATCH] Add option to hide openapi label --- mimic3_http/app.py | 24 +++++++++++++----------- mimic3_http/args.py | 3 +++ mimic3_http/templates/index.html | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/mimic3_http/app.py b/mimic3_http/app.py index e16c2aa..e9fc8b0 100644 --- a/mimic3_http/app.py +++ b/mimic3_http/app.py @@ -296,17 +296,19 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str): return Response(wav_bytes, mimetype="audio/wav") # Swagger UI - try: - api_doc( - app, - config_path=_DIR / "swagger.yaml", - url_prefix="/openapi", - title="Mimic 3", - ) - except Exception: - # Fails with PyInstaller for some reason - _LOGGER.exception("Error setting up swagger UI page") - show_openapi = False + show_openapi = not args.no_show_openapi + if show_openapi: + try: + api_doc( + app, + config_path=_DIR / "swagger.yaml", + url_prefix="/openapi", + title="Mimic 3", + ) + except Exception: + # Fails with PyInstaller for some reason + _LOGGER.exception("Error setting up swagger UI page") + show_openapi = False @app.errorhandler(Exception) async def handle_error(err) -> typing.Tuple[str, int]: diff --git a/mimic3_http/args.py b/mimic3_http/args.py index 0110bf2..f854024 100644 --- a/mimic3_http/args.py +++ b/mimic3_http/args.py @@ -90,6 +90,9 @@ def get_args(argv=None) -> argparse.Namespace: "--default-voice", help="Default voice key to select in web interface", ) + parser.add_argument( + "--no-show-openapi", action="store_true", help="Don't show OpenAPI link" + ) parser.add_argument( "--debug", action="store_true", help="Print DEBUG messages to console" ) diff --git a/mimic3_http/templates/index.html b/mimic3_http/templates/index.html index c7ab08f..5a875a6 100644 --- a/mimic3_http/templates/index.html +++ b/mimic3_http/templates/index.html @@ -86,8 +86,9 @@
- {% if show_openapi %}

+ + {% if show_openapi %} API {% endif %}