feat(api): add gzip middleware

On our local installs this will be a very minor change. For those running on remote servers, load times should be slightly improved.

It's a small change but I think correct.
This commit is contained in:
psychedelicious 2023-10-18 13:42:34 +11:00
parent ef14ba1713
commit e4c45012f4

View File

@ -17,6 +17,7 @@ if True: # hack to make flake8 happy with imports coming after setting up the c
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
from fastapi.openapi.utils import get_openapi
from fastapi.staticfiles import StaticFiles
@ -72,6 +73,8 @@ app.add_middleware(
allow_headers=app_config.allow_headers,
)
app.add_middleware(GZipMiddleware, minimum_size=1000)
# Add startup event to load dependencies
@app.on_event("startup")