-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyapp.py
44 lines (40 loc) · 950 Bytes
/
myapp.py
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
import requests
import json
URL = 'http://127.0.0.1:8000/student/'
def get_data(i=None):
data = {}
if i is not None:
data = {'id':i}
json_data = json.dumps(data)
r = requests.get(url=URL,data=json_data)
data = r.json()
print(data)
# get_data()
def post_data():
data = {
'name':'harshada',
'city':'pune',
'phone':'1234567890'
}
json_data = json.dumps(data)
r = requests.post(url=URL,data=json_data)
data = r.json()
print(data)
post_data()
def update_data():
data = {
'id':1,
'name':'kiran'
}
json_data = json.dumps(data)
r = requests.put(url=URL, data=json_data)
data = r.json()
print(data)
# update_data()
def delete_data():
data = {'id':5}
json_data = json.dumps(data)
r = requests.delete(url=URL,data=json_data)
data = r.json()
print(data)
# delete_data()