44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import requests
|
|
import json
|
|
import os
|
|
|
|
url="http://127.0.0.1:8000"
|
|
|
|
# Does the user have an active account?
|
|
active_account = input("Do you have an account? (y/n): ")
|
|
if active_account == "y":
|
|
email = input("Enter your email: ")
|
|
password = input("Enter your password: ")
|
|
|
|
data = {
|
|
"email": email,
|
|
"password": password
|
|
}
|
|
|
|
response = requests.post(f"{url}/verify", json=data)
|
|
|
|
if response.status_code == 200:
|
|
print("Authentication Successful")
|
|
print(response.json())
|
|
else:
|
|
print("Authentication Not Successful")
|
|
else:
|
|
create_account = input("Do you want to create an account? (y/n): ")
|
|
if create_account.lower() == "y":
|
|
name = input("Enter your name: ")
|
|
email = input("Enter your email: ")
|
|
password = input("Enter your password: ")
|
|
|
|
data = {
|
|
"name": name,
|
|
"email": email,
|
|
"password": password
|
|
}
|
|
|
|
response = requests.post(f"{url}/heroes/create", json=data)
|
|
|
|
if response.status_code == 200:
|
|
print("Authentication Successful")
|
|
print(response.json())
|
|
else:
|
|
print("Authentication Unsuccessful") |