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: