adds (http requests) header class

This commit is contained in:
2026-01-27 16:44:55 +01:00
parent 31109a423f
commit 27b2f5cd94

17
src/classes.py Normal file
View File

@@ -0,0 +1,17 @@
class Header:
'''
Class to standardize the format of the headers of our http requests.
'''
def __init__(self, apikey=""):
'''Init method, apikey suggested but not required (empty by default).'''
self.auth = {"Authorization" : apikey}
self.content = {"Content-Type" : "application/json"}
def dump(self):
'''Dumps the header in form of a dictionary.'''
dump = {**self.auth, **self.content}
return dump
if __name__=="__main__":
head = Header("MyApiKey-123456789abcdef")
print(f"Example header: {head.dump()}")
print("Warning: you're not supposed to be running this as the main program.")