-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_code.py
More file actions
29 lines (24 loc) · 1.01 KB
/
simple_code.py
File metadata and controls
29 lines (24 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# @app.get("/students")
# def get_students():
# Students = []
# for student in collection.find():
# student["_id"] = str(student["_id"])
# Students.append(student)
# return Students
# @app.post("/students")
# def add_students(new_student:Student):
# newstudent = collection.insert_one(new_student.model_dump())
# return f"id : { str(newstudent.inserted_id)}, waa la diwaan galiyay"
# @app.put("/students/{Id}")
# def update_student(Id:str,student_info:Student):
# student = collection.update_one({"_id": ObjectId(Id)}, {"$set":student_info.model_dump()})
# if student.modified_count == 1:
# return f"Waa La Cusboonaysiiyay"
# raise HTTPException(status_code=400, detail="qalad ayaa jira")
# @app.delete("/student/{Id}")
# def delete_student(Id:str):
# deleted = collection.delete_one({"_id": ObjectId(Id)})
# if deleted.deleted_count == 1:
# return "waa la masaxay"
# else:
# raise HTTPException(status_code=404, detail="ardaygan maan helin")