style: 优化添加中间件函数注释
This commit is contained in:
@@ -3,6 +3,12 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
|
||||
def add_cors_middleware(app: FastAPI):
|
||||
"""
|
||||
添加跨域中间件
|
||||
|
||||
:param app: FastAPI对象
|
||||
:return:
|
||||
"""
|
||||
# 前端页面url
|
||||
origins = [
|
||||
'http://localhost:80',
|
||||
|
@@ -3,4 +3,10 @@ from starlette.middleware.gzip import GZipMiddleware
|
||||
|
||||
|
||||
def add_gzip_middleware(app: FastAPI):
|
||||
"""
|
||||
添加gzip压缩中间件
|
||||
|
||||
:param app: FastAPI对象
|
||||
:return:
|
||||
"""
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=9)
|
||||
|
Reference in New Issue
Block a user