mirror of
https://github.com/open-webui/open-webui
synced 2025-01-01 08:42:14 +00:00
Merge pull request #7905 from devdev999/make-swagger-available-offline
feat: make swagger docs available offline
This commit is contained in:
commit
08398e511e
@ -27,8 +27,10 @@ from fastapi import (
|
|||||||
Request,
|
Request,
|
||||||
UploadFile,
|
UploadFile,
|
||||||
status,
|
status,
|
||||||
|
applications
|
||||||
)
|
)
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.openapi.docs import get_swagger_ui_html
|
||||||
from fastapi.responses import JSONResponse, RedirectResponse
|
from fastapi.responses import JSONResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
@ -1105,6 +1107,15 @@ async def healthcheck_with_db():
|
|||||||
|
|
||||||
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
||||||
app.mount("/cache", StaticFiles(directory=CACHE_DIR), name="cache")
|
app.mount("/cache", StaticFiles(directory=CACHE_DIR), name="cache")
|
||||||
|
def swagger_monkey_patch(*args, **kwargs):
|
||||||
|
return get_swagger_ui_html(
|
||||||
|
*args,
|
||||||
|
**kwargs,
|
||||||
|
swagger_js_url="/static/swagger-ui/swagger-ui-bundle.js",
|
||||||
|
swagger_css_url="/static/swagger-ui/swagger-ui.css",
|
||||||
|
swagger_favicon_url="/static/swagger-ui/favicon.png"
|
||||||
|
)
|
||||||
|
applications.get_swagger_ui_html = swagger_monkey_patch
|
||||||
|
|
||||||
if os.path.exists(FRONTEND_BUILD_DIR):
|
if os.path.exists(FRONTEND_BUILD_DIR):
|
||||||
mimetypes.add_type("text/javascript", ".js")
|
mimetypes.add_type("text/javascript", ".js")
|
||||||
|
BIN
backend/open_webui/static/swagger-ui/favicon.png
Normal file
BIN
backend/open_webui/static/swagger-ui/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
File diff suppressed because one or more lines are too long
3
backend/open_webui/static/swagger-ui/swagger-ui.css
Normal file
3
backend/open_webui/static/swagger-ui/swagger-ui.css
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user