-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarefa.py
executable file
·47 lines (36 loc) · 1.03 KB
/
tarefa.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
45
46
#!/usr/bin/python3
import sys
import requests
import json
import os
var = os.environ.get('END')
end = str(var)
print('endereco: ', end)
if sys.argv[1] == 'adicionar':
t = sys.argv[2]
d = sys.argv[3]
s = sys.argv[4]
h = {'content-type': 'application/json'}
dp = {'title': t, 'description': d, 'done': s}
r = requests.post(end + '/Tarefa', data=json.dumps(dp), headers=h)
print(r.text)
elif sys.argv[1] == 'listar':
r = requests.get(end + '/Tarefa')
print(r.text)
elif sys.argv[1] == 'buscar':
t_id = sys.argv[2]
r = requests.get(end + '/Tarefa/' + t_id)
print(r.text)
elif sys.argv[1] == 'apagar':
t_id = sys.argv[2]
r = requests.delete(end + '/Tarefa/' + t_id)
print(r.text)
elif sys.argv[1] == 'atualizar':
t_id = sys.argv[2]
t = sys.argv[3]
d = sys.argv[4]
s = sys.argv[5]
h = {'content-type': 'application/json'}
dp = {'title': t, 'description': d, 'done': s}
r = requests.put(end + '/Tarefa/'+ t_id, data=json.dumps(dp), headers=h)
print(r.text)