-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_api.py
36 lines (29 loc) · 910 Bytes
/
local_api.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
import requests
# TODO: send a GET using the URL http://127.0.0.1:8000
r = requests.get("http://127.0.0.1:8000")
# TODO: print the status code
print("GET Request Status Code:", r.status_code)
# TODO: print the welcome message
print("GET Request Response:", r.text)
data = {
"age": 37,
"workclass": "Private",
"fnlgt": 178356,
"education": "HS-grad",
"education-num": 10,
"marital-status": "Married-civ-spouse",
"occupation": "Prof-specialty",
"relationship": "Husband",
"race": "White",
"sex": "Male",
"capital-gain": 0,
"capital-loss": 0,
"hours-per-week": 40,
"native-country": "United-States",
}
# TODO: send a POST using the data above
r = requests.post("http://127.0.0.1:8000/data/", json=data)
# TODO: print the status code
print("POST Request Status Code:", r.status_code)
# TODO: print the result
print("POST Request Response:", r.json())