From b51ee3db6945e1809cfe1271a3dde43ad8621f89 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Tue, 31 Oct 2023 00:53:04 +0300 Subject: [PATCH] fix mod --- server.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index 634f042..300bc86 100644 --- a/server.py +++ b/server.py @@ -82,17 +82,17 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo if os.path.exists(f"{dir_file}/{filename}"): os.remove(f"{dir_file}/{filename}") - with open(f"{dir_file}/{filename}", 'a') as f: - f.write(str(contents)) + with open(f"{dir_file}/{filename}", 'wb') as f: + f.write(contents) if os.path.exists(f"{dir_last}/{filename}"): os.remove(f"{dir_last}/{filename}") - with open(f"{dir_last}/{filename}", 'a') as f: - f.write(str(contents)) + with open(f"{dir_last}/{filename}", 'wb') as f: + f.write(contents) if stable: if os.path.exists(f"{dir_stable}/{filename}"): os.remove(f"{dir_stable}/{filename}") - with open(f"{dir_stable}/{filename}", 'a') as f: - f.write(str(contents)) + with open(f"{dir_stable}/{filename}", 'wb') as f: + f.write(contents) except Exception as err: return {"message": "There was an error uploading the file, error {err}".format(err=err)} finally: