Prechádzať zdrojové kódy

Transférer les fichiers vers ''

Alexis BALAGUER 1 rok pred
rodič
commit
6d1448b199
1 zmenil súbory, kde vykonal 25 pridanie a 0 odobranie
  1. 25 0
      upload.py

+ 25 - 0
upload.py

@@ -0,0 +1,25 @@
+from fastapi import FastAPI, File, UploadFile
+from pathlib import Path
+
+
+
+app = FastAPI()
+
+@app.post("/pushUpdate/{branch}/{version}/{os}")
+async def push_update(file: UploadFile, branch: str,version: str,os: str):
+    nfile = Path(f'{branch}/{version}/{os}/{file.filename}')
+    nfile.parent.mkdir(parents=True, exist_ok=True)
+    print(f'{branch}/{version}/{os}/{file.filename}')
+    with open(f'{branch}/{version}/{os}/{file.filename}',"w") as f :
+        content = await file.read()
+        f.write(content.decode())
+        f.close()
+    return {"filename": file.filename}
+
+@app.post("/uploadfile/")
+async def create_upload_file(file: UploadFile):
+    with open(file.filename,"w") as f :
+        content = await file.read()
+        f.write(content.decode())
+        f.close()
+    return {"filename": file.filename}