Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -985,8 +985,19 @@ def classify(payload: dict[str, Any]) -> dict[str, Any]:
|
|
| 985 |
|
| 986 |
@app.post("/v1/compress")
|
| 987 |
async def compress(request: Request) -> dict[str, Any]:
|
|
|
|
| 988 |
try:
|
| 989 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
except Exception as exc:
|
| 991 |
raise HTTPException(status_code=400, detail="invalid JSON body") from exc
|
| 992 |
if not isinstance(payload, dict):
|
|
|
|
| 985 |
|
| 986 |
@app.post("/v1/compress")
|
| 987 |
async def compress(request: Request) -> dict[str, Any]:
|
| 988 |
+
raw = await request.body()
|
| 989 |
try:
|
| 990 |
+
body, _ = _decode_request_body(
|
| 991 |
+
raw,
|
| 992 |
+
request.headers.get(CONTENT_ENCODING_HEADER)
|
| 993 |
+
or request.headers.get(TOUCHDOWN_CONTENT_ENCODING_HEADER),
|
| 994 |
+
)
|
| 995 |
+
except UnsupportedContentEncoding as exc:
|
| 996 |
+
raise HTTPException(status_code=415, detail=str(exc)) from exc
|
| 997 |
+
except ValueError as exc:
|
| 998 |
+
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
| 999 |
+
try:
|
| 1000 |
+
payload = json.loads(body.decode("utf-8")) if body else {}
|
| 1001 |
except Exception as exc:
|
| 1002 |
raise HTTPException(status_code=400, detail="invalid JSON body") from exc
|
| 1003 |
if not isinstance(payload, dict):
|