z230
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# app.py | v1.0 | 2026-05-29
|
||||
# FastAPI server pro příjem .msg a .db souborů a upload do Dropboxu.
|
||||
# Endpointy: /upload (.msg → /msgs), /upload-db (.db → /msgs/db), /upload-dropbox (→ Dropbox /!!!Days/Downloads Z230).
|
||||
|
||||
from fastapi import FastAPI, UploadFile, File, Header, HTTPException
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
@@ -47,6 +51,8 @@ async def upload_db(
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
if not file.filename.endswith(".db"):
|
||||
raise HTTPException(status_code=400, detail="Only .db files accepted")
|
||||
for old in DB_DIR.glob("*.db"):
|
||||
old.unlink()
|
||||
dest = DB_DIR / file.filename
|
||||
with dest.open("wb") as f:
|
||||
shutil.copyfileobj(file.file, f)
|
||||
|
||||
Reference in New Issue
Block a user