From b20dc6ab8ab14f961db29937eb6dc43a951b32e4 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Wed, 8 Mar 2023 17:20:15 +0800 Subject: [PATCH] Use gzip middleware --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index fb7262c..12b474c 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ from pydantic import BaseModel from starlette.responses import FileResponse, JSONResponse from fastapi import FastAPI, File, UploadFile, Response, status, Request, Body from fastapi.responses import PlainTextResponse +from fastapi.middleware.gzip import GZipMiddleware from tjnetwork import * JUNCTION = 0 @@ -31,6 +32,8 @@ if not os.path.exists(tmpDir): app = FastAPI() +app.add_middleware(GZipMiddleware, minimum_size=1000) + ### project @app.get('/listprojects/') @@ -180,7 +183,7 @@ async def fastapi_take_snapshot_for_current_operation(network: str, tag: str) -> return take_snapshot_for_current_operation(network, tag) @app.post('/takesnapshot/') -def fastapi_take_snapshot(network: str, tag: str) -> int | None: +def fastapi_take_snapshot(network: str, tag: str) -> None: return take_snapshot(network, tag) @app.post('/picksnapshot/')