Use gzip middleware

This commit is contained in:
DingZQ
2023-03-08 17:20:15 +08:00
parent 11a3cb7a78
commit b20dc6ab8a

View File

@@ -8,6 +8,7 @@ from pydantic import BaseModel
from starlette.responses import FileResponse, JSONResponse from starlette.responses import FileResponse, JSONResponse
from fastapi import FastAPI, File, UploadFile, Response, status, Request, Body from fastapi import FastAPI, File, UploadFile, Response, status, Request, Body
from fastapi.responses import PlainTextResponse from fastapi.responses import PlainTextResponse
from fastapi.middleware.gzip import GZipMiddleware
from tjnetwork import * from tjnetwork import *
JUNCTION = 0 JUNCTION = 0
@@ -31,6 +32,8 @@ if not os.path.exists(tmpDir):
app = FastAPI() app = FastAPI()
app.add_middleware(GZipMiddleware, minimum_size=1000)
### project ### project
@app.get('/listprojects/') @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) return take_snapshot_for_current_operation(network, tag)
@app.post('/takesnapshot/') @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) return take_snapshot(network, tag)
@app.post('/picksnapshot/') @app.post('/picksnapshot/')