aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2023-05-04 16:34:47 -0700
committerPinapelz <donaldshan1@outlook.com>2023-05-04 16:34:47 -0700
commit2878c453ec7d7b5874fc9734dbf423963dd9ca2f (patch)
tree993cea5fa5d2bc33708f63c57e49a45cdcb5abaa
parent95f604cc62a96b31e2ac0797e447e09b9158efb3 (diff)
Added option to specify header name for different apis
-rw-r--r--webapi/web_api.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/webapi/web_api.py b/webapi/web_api.py
index 1b16681..525994c 100644
--- a/webapi/web_api.py
+++ b/webapi/web_api.py
@@ -11,7 +11,7 @@ class WebAPI:
self.api_key = api_key
self.base_url = base_url
- def _download_url(self, query: str) -> dict:
+ def _download_url(self, query: str, header = 'X-APIKEY') -> dict:
"""
Downloads the URL and returns the result as a string
param:
@@ -20,7 +20,7 @@ class WebAPI:
if self.api_key is None:
raise Exception("API key not set")
opener = urllib.request.build_opener()
- opener.addheaders = [('X-APIKEY', self.api_key)]
+ opener.addheaders = [(header, self.api_key)]
urllib.request.install_opener(opener)
response = urllib.request.urlopen(self.base_url + query)
json_results = response.read()
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage