Add gzip compression middleware
This commit is contained in:
parent
3b50678d0a
commit
cd2b0c0ca1
1 changed files with 5 additions and 0 deletions
|
@ -3,6 +3,7 @@ import argparse
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.middleware.gzip import GZipMiddleware
|
||||||
|
|
||||||
from src import database
|
from src import database
|
||||||
from src.routes.projects import router as project_router
|
from src.routes.projects import router as project_router
|
||||||
|
@ -43,6 +44,10 @@ app.add_middleware(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Add HTTP compression for responses with more than 500 bytes
|
||||||
|
app.add_middleware(GZipMiddleware)
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
def on_startup():
|
def on_startup():
|
||||||
"""Code executed on HTTP server startup. Until now only creating databases and tables."""
|
"""Code executed on HTTP server startup. Until now only creating databases and tables."""
|
||||||
|
|
Loading…
Reference in a new issue