From c04e3c5666531e02cb2c462d7e3b97e6f1284537 Mon Sep 17 00:00:00 2001 From: vfbd Date: Mon, 8 Aug 2022 18:21:46 -0400 Subject: [PATCH] Fix /docs/ redirects --- aiserver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index d47fa562..4ec1e7e6 100644 --- a/aiserver.py +++ b/aiserver.py @@ -523,7 +523,9 @@ class KoboldAPISpec(APISpec): self._prefixes = prefixes if prefixes is not None else [""] super().__init__(*args, title=title, openapi_version=openapi_version, plugins=plugins, servers=[{"url": self._prefixes[0]}], **kwargs) for prefix in self._prefixes: - app.route(prefix, endpoint="~KoboldAPISpec~" + prefix, strict_slashes=False)(app.route(prefix + "/docs", endpoint="~KoboldAPISpec~" + prefix + "/docs")(lambda: redirect(prefix + "/docs/"))) + app.route(prefix, endpoint="~KoboldAPISpec~" + prefix)(lambda: redirect(request.path + "/docs/")) + app.route(prefix + "/", endpoint="~KoboldAPISpec~" + prefix + "/")(lambda: redirect("docs/")) + app.route(prefix + "/docs", endpoint="~KoboldAPISpec~" + prefix + "/docs")(lambda: redirect("docs/")) app.route(prefix + "/docs/", endpoint="~KoboldAPISpec~" + prefix + "/docs/")(lambda: render_template("swagger-ui.html", url=self._prefixes[0] + "/openapi.json")) app.route(prefix + "/openapi.json", endpoint="~KoboldAPISpec~" + prefix + "/openapi.json")(lambda: jsonify(self.to_dict()))