-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcrud_api.py
More file actions
38 lines (31 loc) · 987 Bytes
/
crud_api.py
File metadata and controls
38 lines (31 loc) · 987 Bytes
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
30
31
32
33
34
35
36
37
38
import CRUD as c
from fastapi import FastAPI
import logger as l
app = FastAPI()
@app.post("/create_note")
def create_note_api(data: dict):
filename, subject, other_info, content = (
data['filename'],
data['subject'],
data['other_info'],
data['content'],
)
c.create_note()
return {"message": "Note created successfully"}
@app.get("/read_notes")
def read_notes_api():
notes = c.read_notes()
return {"notes": notes}
@app.put("/update_note")
def update_note_api(data: dict):
filename, content = data['filename'], data['content']
c.update_note(filename,content)
return {"message": "Note updated successfully"}
@app.delete("/delete_note")
def delete_note_api(data: dict):
filename = data['filename']
c.delete_note(filename)
return {"message": "Note deleted successfully"}
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)