diff --git a/optuna_dashboard/app.py b/optuna_dashboard/app.py index 8b0dfdaf..7ddd35a3 100644 --- a/optuna_dashboard/app.py +++ b/optuna_dashboard/app.py @@ -7,7 +7,7 @@ import threading import traceback from typing import Union, Dict, List, Optional -from bottle import Bottle, redirect, request, response, static_file +from bottle import Bottle, redirect, request, response, static_file, hook from optuna.exceptions import DuplicatedStudyError from optuna.storages import BaseStorage, get_storage from optuna.trial import FrozenTrial @@ -95,6 +95,10 @@ def create_app(storage_or_url: Union[str, BaseStorage]) -> Bottle: app = Bottle() storage = get_storage(storage_or_url) + @hook('before_request') + def remove_trailing_slashes_hook(): + request.environ['PATH_INFO'] = request.environ['PATH_INFO'].rstrip('/') + @app.get("/") def index(): return redirect("/dashboard", 302) # Status Found