# -*- encoding: utf-8 -*-
from http_request import RequestHttp
URL = "127.0.0.1/api/"
class Headers:
def __init__(self):
self.host = URL
self.base_url = "http://" + self.host
#请求登录,获取授权返回
def get_login_authorization(self):
request = RequestHttp()
response = request.request_http(
method='POST',
url=self.base_url + "login",
json={
"username": "admin",
"password": "123456",
"uuid": "360bf1a4cf9e46f387521fca331a6c4f"
},
headers=None
).json()
Authorization = "Bearer " + response["data"]
return Authorization
def create_headers(self):
Authorization = self.get_login_authorization()
headers = {"Authorization": Authorization,
"content-type": "application/json"}
headers["Accept"] = "application/json, text/plain, */*"
return headers
if __name__ == "__main__":
hd = Headers()
headers = hd.create_headers()
print(headers)
08-12
434