@@ -108,6 +108,7 @@ class PyPortal:
108
108
"""Class representing the Adafruit PyPortal.
109
109
110
110
:param url: The URL of your data source. Defaults to ``None``.
111
+ :param headers: The headers for authentication, typically used by Azure API's.
111
112
:param json_path: The list of json traversal to get data out of. Can be list of lists for
112
113
multiple data points. Defaults to ``None`` to not use json.
113
114
:param regexp_path: The list of regexp strings to get data out (use a single regexp group). Can
@@ -144,7 +145,7 @@ class PyPortal:
144
145
145
146
"""
146
147
# pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements
147
- def __init__ (self , * , url = None , json_path = None , regexp_path = None ,
148
+ def __init__ (self , * , url = None , headers = None , json_path = None , regexp_path = None ,
148
149
default_bg = 0x000000 , status_neopixel = None ,
149
150
text_font = None , text_position = None , text_color = 0x808080 ,
150
151
text_wrap = False , text_maxlen = 0 , text_transform = None ,
@@ -162,6 +163,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None,
162
163
self .set_backlight (1.0 ) # turn on backlight
163
164
164
165
self ._url = url
166
+ self ._headers = headers
165
167
if json_path :
166
168
if isinstance (json_path [0 ], (list , tuple )):
167
169
self ._json_path = json_path
@@ -666,7 +668,7 @@ def fetch(self):
666
668
print ("Retrieving data..." , end = '' )
667
669
self .neo_status ((100 , 100 , 0 )) # yellow = fetching data
668
670
gc .collect ()
669
- r = requests .get (self ._url )
671
+ r = requests .get (self ._url , headers = self . _headers )
670
672
gc .collect ()
671
673
self .neo_status ((0 , 0 , 100 )) # green = got data
672
674
print ("Reply is OK!" )
0 commit comments