From e928d2991ddb4ff67aa2d52fda5caf78052e14b9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Jan 2021 10:27:15 +0100 Subject: [PATCH] Add fallback file --- freqtrade/commands/deploy_commands.py | 2 +- .../rpc/api_server/ui/fallback_file.html | 31 +++++++++++++++++++ freqtrade/rpc/api_server/web_ui.py | 5 ++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 freqtrade/rpc/api_server/ui/fallback_file.html diff --git a/freqtrade/commands/deploy_commands.py b/freqtrade/commands/deploy_commands.py index b9bda9c63..8a8d2373e 100644 --- a/freqtrade/commands/deploy_commands.py +++ b/freqtrade/commands/deploy_commands.py @@ -146,7 +146,7 @@ def clean_ui_subdir(directory: Path): logger.info("Removing UI directory content.") for p in reversed(list(directory.glob('**/*'))): # iterate contents from leaves to root - if p.name == '.gitkeep': + if p.name in ('.gitkeep', 'fallback_file.html'): continue if p.is_file(): p.unlink() diff --git a/freqtrade/rpc/api_server/ui/fallback_file.html b/freqtrade/rpc/api_server/ui/fallback_file.html new file mode 100644 index 000000000..7943530af --- /dev/null +++ b/freqtrade/rpc/api_server/ui/fallback_file.html @@ -0,0 +1,31 @@ + + + + + + Freqtrade UI + + + +
+

Freqtrade UI not installed.

+

Please run `freqtrade install-ui` in your terminal to install the UI files and restart your bot.

+

You can then refresh this page and you should see the UI.

+
+ + diff --git a/freqtrade/rpc/api_server/web_ui.py b/freqtrade/rpc/api_server/web_ui.py index 971f9e4de..6d397da56 100644 --- a/freqtrade/rpc/api_server/web_ui.py +++ b/freqtrade/rpc/api_server/web_ui.py @@ -24,5 +24,8 @@ async def index_html(rest_of_path: str): if (uibase / rest_of_path).is_file(): return FileResponse(uibase / rest_of_path) + index_file = uibase / 'index.html' + if not index_file.is_file(): + return FileResponse(uibase / 'fallback_file.html') # Fall back to index.html, as indicated by vue router docs - return FileResponse(uibase / 'index.html') + return FileResponse(index_file)