Spaces:
Sleeping
Sleeping
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@app.post("/file/upload")
|
| 2 |
+
async def upload_file(username: str, uploaded_file: UploadFile = File(...)):
|
| 3 |
+
path_to_save_file = Path.home() / username / "saved_files"
|
| 4 |
+
path_to_save_file.mkdir(parents=True, exist_ok=True)
|
| 5 |
+
file_location = f"{path_to_save_file}/{uploaded_file.filename}"
|
| 6 |
+
with open(file_location, "wb+") as file_object:
|
| 7 |
+
file_object.write(uploaded_file.file.read())
|
| 8 |
+
return {"INFO": f"File '{uploaded_file.filename}' saved to your profile."}
|