27 lines
536 B
Python
27 lines
536 B
Python
import requests
|
|
|
|
conn = requests.Session()
|
|
url = "http://127.0.0.1"
|
|
r = conn.get(url)
|
|
# print(r.json())
|
|
print(r.headers)
|
|
# url = "http://127.0.0.1/login"
|
|
# data = {
|
|
# "username": "admin",
|
|
# "password": "admin123"
|
|
# }
|
|
# r = requests.post(url, json=data)
|
|
# print(r.json())
|
|
# token = r.headers.get("set-cookie")
|
|
# headers = {
|
|
# "Cookie": token
|
|
# }
|
|
# print(token)
|
|
url = "http://127.0.0.1/users/me"
|
|
token = r.headers.get('set-cookie')
|
|
headers = {
|
|
"Cookie": f"token={token}"
|
|
}
|
|
r = conn.get(url, headers=headers)
|
|
print(r.text)
|