From 59287448c1a2b5aa0cc1fb5eca4489802fffef75 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 17 Jan 2022 19:37:40 -0600 Subject: [PATCH] forced content type --- adafruit_pyportal/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adafruit_pyportal/__init__.py b/adafruit_pyportal/__init__.py index 3a1f750..46ca991 100755 --- a/adafruit_pyportal/__init__.py +++ b/adafruit_pyportal/__init__.py @@ -295,7 +295,7 @@ def set_caption(self, caption_text, caption_position, caption_color): ) self.set_text(caption_text, index) - def fetch(self, refresh_url=None, timeout=10): + def fetch(self, refresh_url=None, timeout=10, force_content_type=None): """Fetch data from the url we initialized with, perfom any parsing, and display text or graphics. This function does pretty much everything Optionally update the URL @@ -307,7 +307,10 @@ def fetch(self, refresh_url=None, timeout=10): response = self.network.fetch(self.url, headers=self._headers, timeout=timeout) json_out = None - content_type = self.network.check_response(response) + if not force_content_type: + content_type = self.network.check_response(response) + else: + content_type = force_content_type json_path = self._json_path if content_type == CONTENT_JSON: