diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index ba5d2bd5..2920b815 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -49,83 +49,8 @@ logger = logging.getLogger(__name__) BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_DIR = os.path.join(BASE_DIR, "public") +IMG_DIR = os.path.join(BASE_DIR, "img") -INDEX_HTML = """ - - - Optuna Dashboard - - - - - - -
- - - - - - - -

NOW LOADING

-
-
- - -""" # noqa:E501 # In-memory trials cache trials_cache_lock = threading.Lock() trials_cache: Dict[int, List[FrozenTrial]] = {} @@ -191,8 +116,7 @@ def create_app(storage: BaseStorage) -> Bottle: # Accept any following paths for client-side routing @app.get("/dashboard<:re:(/.*)?>") def dashboard() -> BottleViewReturn: - response.content_type = "text/html" - return INDEX_HTML + return static_file("index.html", BASE_DIR, mimetype="text/html") @app.get("/api/studies") @json_api_view @@ -324,6 +248,12 @@ def create_app(storage: BaseStorage) -> Bottle: response.status = 204 # No content return {} + @app.get("/favicon.ico") + def favicon() -> BottleViewReturn: + use_gzip = "gzip" in request.headers["Accept-Encoding"] + filename = "favicon.ico.gz" if use_gzip else "favicon.ico" + return static_file(filename, IMG_DIR) + @app.get("/static/") def send_static(filename: str) -> BottleViewReturn: return static_file(filename, root=STATIC_DIR) diff --git a/optuna_dashboard/img/favicon.ico b/optuna_dashboard/img/favicon.ico new file mode 100644 index 00000000..3b07f073 Binary files /dev/null and b/optuna_dashboard/img/favicon.ico differ diff --git a/optuna_dashboard/img/favicon.ico.gz b/optuna_dashboard/img/favicon.ico.gz new file mode 100644 index 00000000..3a259190 Binary files /dev/null and b/optuna_dashboard/img/favicon.ico.gz differ diff --git a/optuna_dashboard/index.html b/optuna_dashboard/index.html new file mode 100644 index 00000000..ec437f11 --- /dev/null +++ b/optuna_dashboard/index.html @@ -0,0 +1,75 @@ + + + + Optuna Dashboard + + + + + + +
+ + + + + + + +

NOW LOADING

+
+
+ + \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 28087f69..c9886d70 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,10 @@ console_scripts = optuna-dashboard = optuna_dashboard._cli:main [options.package_data] -optuna_dashboard = public/* +optuna_dashboard = + public/* + img/* + index.html [options.packages.find] exclude =