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()))