Add option to hide openapi label
This commit is contained in:
parent
1c61700b4c
commit
caaefdaa93
3 changed files with 18 additions and 12 deletions
|
|
@ -296,17 +296,19 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str):
|
||||||
return Response(wav_bytes, mimetype="audio/wav")
|
return Response(wav_bytes, mimetype="audio/wav")
|
||||||
|
|
||||||
# Swagger UI
|
# Swagger UI
|
||||||
try:
|
show_openapi = not args.no_show_openapi
|
||||||
api_doc(
|
if show_openapi:
|
||||||
app,
|
try:
|
||||||
config_path=_DIR / "swagger.yaml",
|
api_doc(
|
||||||
url_prefix="/openapi",
|
app,
|
||||||
title="Mimic 3",
|
config_path=_DIR / "swagger.yaml",
|
||||||
)
|
url_prefix="/openapi",
|
||||||
except Exception:
|
title="Mimic 3",
|
||||||
# Fails with PyInstaller for some reason
|
)
|
||||||
_LOGGER.exception("Error setting up swagger UI page")
|
except Exception:
|
||||||
show_openapi = False
|
# Fails with PyInstaller for some reason
|
||||||
|
_LOGGER.exception("Error setting up swagger UI page")
|
||||||
|
show_openapi = False
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
@app.errorhandler(Exception)
|
||||||
async def handle_error(err) -> typing.Tuple[str, int]:
|
async def handle_error(err) -> typing.Tuple[str, int]:
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,9 @@ def get_args(argv=None) -> argparse.Namespace:
|
||||||
"--default-voice",
|
"--default-voice",
|
||||||
help="Default voice key to select in web interface",
|
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(
|
parser.add_argument(
|
||||||
"--debug", action="store_true", help="Print DEBUG messages to console"
|
"--debug", action="store_true", help="Print DEBUG messages to console"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,9 @@
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button id="speak-button" name="speak" class="btn btn-lg btn-primary" alt="Generate speech">Speak</button>
|
<button id="speak-button" name="speak" class="btn btn-lg btn-primary" alt="Generate speech">Speak</button>
|
||||||
|
|
||||||
{% if show_openapi %}
|
|
||||||
<br/><br />
|
<br/><br />
|
||||||
|
|
||||||
|
{% if show_openapi %}
|
||||||
<a href="/openapi/" title="OpenAPI page" target="_blank" class="badge badge-info">API</a>
|
<a href="/openapi/" title="OpenAPI page" target="_blank" class="badge badge-info">API</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue