fastapi-login/test_client.py
2024-01-14 17:09:42 +08:00

18 lines
313 B
Python

import requests
url = "http://127.0.0.1/login"
data = {
"username": "admin",
"password": "admin123"
}
r = requests.post(url, json=data)
token = r.json()["access_token"]
headers = {
"Cookie": token
}
print(token)
url = "http://127.0.0.1/users/me"
r = requests.get(url, headers=headers)
print(r.text)