-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
63 lines (43 loc) · 1.33 KB
/
app.py
File metadata and controls
63 lines (43 loc) · 1.33 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from flask import Flask,jsonify
app= Flask(__name__)
Full_content=[]
@app.route('/')
def home():
return jsonify({"example_route":[
"/note/view-all",
"/note/create/note1/Mycontentnote1",
"/note/view/note1",
"/note/update/note1/extracontent",
"/note/delete/note1"
]})
@app.route('/note/view-all')
def view_all():
return str(Full_content)
@app.route('/note/create/<title>/<content>')
def create_note(title,content):
mylist= {"title":title, "content":content}
Full_content.append(mylist)
return "saved"
@app.route('/note/view/<title>')
def view_note(title):
for i in Full_content:
if title==i["title"]:
return str(i["content"])
return "not found"
@app.route('/note/update/<title>/<content>')
def update_note(title,content):
for i in Full_content:
if title==i["title"]:
old_content=i["content"]
Total_content= old_content+content
i.update({"content":Total_content})
return "update successful"
return "couldnot find"
@app.route('/note/delete/<title>')
def delete_note(title):
for i in Full_content:
if title==i["title"]:
Full_content.remove(i)
return "delete sucessful"
return "not found"
app.run(debug=False,host="0.0.0.0")