-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrud.py
More file actions
54 lines (42 loc) · 1.32 KB
/
Crud.py
File metadata and controls
54 lines (42 loc) · 1.32 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
from flask import Flask, request,jsonify
from Dao import AllData,specific,create,update,delete,sample
import json
app = Flask(__name__)
@app.route("/name")
def printName():
#check user details from db
# return print_name();
return {"data":print_name()};
def print_name():
return "This is Adil Abdullah";
@app.route("/all",methods=['GET'])
def all_data():
return jsonify(AllData());
@app.route("/specific/<sno>",methods=['GET'])
def specific_data(sno):
return jsonify(specific(sno));
@app.route("/insert",methods=['POST'])
def insert_data():
record = json.loads(request.data)
return jsonify(create(record));
@app.route("/update/<sno>",methods=['PUT'])
def update_data(sno):
record = json.loads(request.data)
return jsonify(update(record,sno));
@app.route("/delete/<sno>",methods=['DELETE'])
def delete_data(sno):
return jsonify(delete(sno));
@app.route("/sample",methods=['POST'])
def sample_data():
record = json.loads(request.data)
#message = json.load(data);
print(record["First_Name"]);
print(record["Last_Name"]);
print(record["Email"]);
print(record["Age"]);
print(record["Cell"]);
return jsonify(record);
# print(data);
# return sample(data);
if __name__ == '__main__':
app.run() # run our Flask app