Spaces:
Runtime error
Runtime error
Update main.py
Browse files65 unmodified lines66676869707165 unmodified linesuser_groups = {name: details for name, details in groups_db.items() if username in details["members"]}return user_groups# اجرای سرور# برای اجرای سرور، کد زیر را در ترمینال اجرا کنید:# uvicorn your_filename:app --reload65 unmodified lines6667686970717273747576777879808182838485868788899091929394959697989965 unmodified linesuser_groups = {name: details for name, details in groups_db.items() if username in details["members"]}return user_groups@app.post("/groups/{group_name}/leave/")def leave_group(group_name: str, username: str = Depends(get_current_user)):if group_name not in groups_db:raise HTTPException(status_code=404, detail="Group not found")if username not in groups_db[group_name]["members"]:raise HTTPException(status_code=400, detail="You are not a member of this group")groups_db[group_name]["members"].remove(username)return {"message": f"You have left the group {group_name}"}@app.post("/delete_account/")def delete_account(username: str = Depends(get_current_user)):if username not in users_db:raise HTTPException(status_code=404, detail="User not found")# حذف کاربر از دیتابیس کاربرانdel users_db[username]# حذف کاربر از تمام گروههایی که عضو آن استfor group in list(groups_db.values()):if username in group["members"]:group["members"].remove(username)if group["owner"] == username:# اگر کاربر مالک گروه بود، گروه را حذف میکنیمdel groups_db[group["group_name"]]return {"message": "Your account has been deleted"}# اجرای سرور# برای اجرای سرور، کد زیر را در ترمینال اجرا کنید:# uvicorn your_filename:app --reload
main.py+28