changes Header.dump from method to attribute
This commit is contained in:
@@ -6,10 +6,7 @@ class Header:
|
|||||||
'''Init method, apikey suggested but not required (empty by default).'''
|
'''Init method, apikey suggested but not required (empty by default).'''
|
||||||
self.auth = {"Authorization" : apikey}
|
self.auth = {"Authorization" : apikey}
|
||||||
self.content = {"Content-Type" : "application/json"}
|
self.content = {"Content-Type" : "application/json"}
|
||||||
def dump(self):
|
self.dump = {**self.auth, **self.content}
|
||||||
'''Dumps the header in form of a dictionary.'''
|
|
||||||
dump = {**self.auth, **self.content}
|
|
||||||
return dump
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
head = Header("MyApiKey-123456789abcdef")
|
head = Header("MyApiKey-123456789abcdef")
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ def get_sample_layers_data(elabid):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
apikey = getpass("Paste API key here: ") # consider replacing with .env file
|
apikey = getpass("Paste API key here: ") # consider replacing with .env file
|
||||||
header = Header(apikey)
|
header = Header(apikey).dump
|
||||||
header = header.dump()
|
|
||||||
result = get_sample_layers_data(1108) # edit id at will in case of deletion of remote source
|
result = get_sample_layers_data(1108) # edit id at will in case of deletion of remote source
|
||||||
print(json.dumps(result))
|
print(json.dumps(result))
|
||||||
Reference in New Issue
Block a user