文档服务本地化
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
__version__="0.3.3"
|
__version__="0.3.4b1"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ from urllib.parse import quote
|
|||||||
import httpx
|
import httpx
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI, HTTPException, APIRouter, Body, Path as FastApiPath
|
from fastapi import FastAPI, HTTPException, APIRouter, Body, Path as FastApiPath
|
||||||
|
from fastapi.openapi.docs import (
|
||||||
|
get_swagger_ui_html,
|
||||||
|
get_swagger_ui_oauth2_redirect_html, get_redoc_html,
|
||||||
|
)
|
||||||
from fastapi.responses import HTMLResponse, JSONResponse, StreamingResponse, FileResponse
|
from fastapi.responses import HTMLResponse, JSONResponse, StreamingResponse, FileResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@@ -271,9 +275,12 @@ tags_metadata = [
|
|||||||
"name": "Temp",
|
"name": "Temp",
|
||||||
"description": "测试用接口。",
|
"description": "测试用接口。",
|
||||||
},
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
|
docs_url=None,
|
||||||
|
redoc_url=None,
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
title="DocuTranslate API",
|
title="DocuTranslate API",
|
||||||
description=f"""
|
description=f"""
|
||||||
@@ -934,6 +941,30 @@ async def main_page_admin():
|
|||||||
return FileResponse(index_path, headers=no_cache_headers)
|
return FileResponse(index_path, headers=no_cache_headers)
|
||||||
|
|
||||||
|
|
||||||
|
###文档服务
|
||||||
|
@app.get("/docs", include_in_schema=False)
|
||||||
|
async def custom_swagger_ui_html():
|
||||||
|
return get_swagger_ui_html(
|
||||||
|
openapi_url=app.openapi_url,
|
||||||
|
title=app.title + " - Swagger UI",
|
||||||
|
oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
|
||||||
|
swagger_js_url="/static/swagger/swagger.js",
|
||||||
|
swagger_css_url="/static/swagger/swagger.css",
|
||||||
|
)
|
||||||
|
|
||||||
|
@app.get(app.swagger_ui_oauth2_redirect_url, include_in_schema=False)
|
||||||
|
async def swagger_ui_redirect():
|
||||||
|
return get_swagger_ui_oauth2_redirect_html()
|
||||||
|
|
||||||
|
@app.get("/redoc", include_in_schema=False)
|
||||||
|
async def redoc_html():
|
||||||
|
return get_redoc_html(
|
||||||
|
openapi_url=app.openapi_url,
|
||||||
|
title=app.title + " - ReDoc",
|
||||||
|
redoc_js_url="/static/redoc/redoc.js",
|
||||||
|
)
|
||||||
|
###
|
||||||
|
|
||||||
@app.post("/temp/translate",
|
@app.post("/temp/translate",
|
||||||
summary="[临时]同步翻译接口",
|
summary="[临时]同步翻译接口",
|
||||||
description="一个简单的、同步的翻译接口,用于快速测试。不涉及后台任务、状态管理或多格式输出。**不建议在生产环境中使用。**",
|
description="一个简单的、同步的翻译接口,用于快速测试。不涉及后台任务、状态管理或多格式输出。**不建议在生产环境中使用。**",
|
||||||
|
|||||||
1832
docutranslate/static/redoc/redoc.js
Normal file
1832
docutranslate/static/redoc/redoc.js
Normal file
File diff suppressed because one or more lines are too long
1
docutranslate/static/swagger/swagger.css
Normal file
1
docutranslate/static/swagger/swagger.css
Normal file
File diff suppressed because one or more lines are too long
2
docutranslate/static/swagger/swagger.js
Normal file
2
docutranslate/static/swagger/swagger.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user