Add GZip compression

This commit is contained in:
magmaus3 2022-11-27 14:24:42 +01:00
parent 43d4e9a825
commit 347143ab44
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251

View file

@ -1,5 +1,6 @@
from typing import Union from typing import Union
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import HTMLResponse, PlainTextResponse from fastapi.responses import HTMLResponse, PlainTextResponse
from fastapi import FastAPI, Form, Response from fastapi import FastAPI, Form, Response
import jinja2 import jinja2
@ -15,6 +16,7 @@ from . import __version__
basedir = os.path.dirname(__file__) basedir = os.path.dirname(__file__)
app = FastAPI(openapi_url=None) app = FastAPI(openapi_url=None)
app.add_middleware(GZipMiddleware)
app.mount("/static", StaticFiles(directory=basedir + "/static"), name="static") app.mount("/static", StaticFiles(directory=basedir + "/static"), name="static")
template_env = jinja2.Environment( template_env = jinja2.Environment(