You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
287 B
13 lines
287 B
6 months ago
|
from fastapi import FastAPI
|
||
|
from starlette.middleware.gzip import GZipMiddleware
|
||
|
|
||
|
|
||
|
def add_gzip_middleware(app: FastAPI):
|
||
6 months ago
|
"""
|
||
|
添加gzip压缩中间件
|
||
|
|
||
|
:param app: FastAPI对象
|
||
|
:return:
|
||
|
"""
|
||
6 months ago
|
app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=9)
|