-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.py
More file actions
33 lines (24 loc) · 1.05 KB
/
util.py
File metadata and controls
33 lines (24 loc) · 1.05 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
import requests
import typer
app = typer.Typer()
@app.command()
def create_user(email:str, password:str):
request = requests.post(
"http://localhost:8080/signup", json={"input":{"email": email, "password": password}})
assert request.ok, f"Failed with code {request.status_code}, error: {request.json()}"
print (request.json())
@app.command()
def login(email:str, password:str):
request = requests.post(
"http://localhost:8080/login", json={"input":{"email": email, "password": password}})
assert request.ok, f"Failed with code {request.status_code}, error: {request.json()}"
return request.json()
@app.command()
def list_animals(email:str, password:str):
token = login(email, password)
request = requests.get(
"http://localhost:8080/animals", json={"input":{"email": email, "password": password}}, headers={"Authorization": f"Bearer {token['token']}"})
assert request.ok, f"Failed with code {request.status_code}, error: {request.json()}"
print (request.json())
if __name__ == "__main__":
app()