43 lines
950 B
Python
43 lines
950 B
Python
from typing import Any
|
|
|
|
import requests
|
|
|
|
url="http://127.0.0.1:8000"
|
|
|
|
def create_account(name: str, email: str, password: str) -> Any | None:
|
|
data = {
|
|
"name": name,
|
|
"email": email,
|
|
"password": password
|
|
}
|
|
|
|
response = requests.post(f"{url}/heroes/create", json=data)
|
|
|
|
if response.status_code == 200:
|
|
return response.json()
|
|
else:
|
|
return False
|
|
|
|
def login(email, password):
|
|
data = {
|
|
"email": email,
|
|
"password": password
|
|
}
|
|
|
|
response = requests.post(f"{url}/verify", json=data)
|
|
|
|
if response.status_code == 200:
|
|
user_response = requests.get(f"{url}/heroes/{response.json()['hero_id']}")
|
|
return user_response.json()
|
|
else:
|
|
return False
|
|
|
|
def load_options() -> int:
|
|
print("""
|
|
Here are the available options:
|
|
* To select an option just enter its number *
|
|
1. Home - View the inventory
|
|
""")
|
|
|
|
option = int(input(""))
|
|
return option |