<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[UIFlow 2.0.1 HTTP GET and parse JSON]]></title><description><![CDATA[<p dir="auto">Hi team,</p>
<p dir="auto">I'm trying to complete the simplest of all possible projects, and for the life of me after two days of troubleshooting I simply can't figure it out.</p>
<p dir="auto">Device: Core2<br />
OS: Mac OS 14.2.1<br />
Software: UIFlow v2.0.1</p>
<p dir="auto">I'm trying to HTTP GET a local JSON endpoint with some data.</p>
<p dir="auto">I started off trying to program this with the visual interface, but found that I quickly had to switch to python because of the missing 'urequests' lib (there's another thread about that on this forum).</p>
<p dir="auto">Using the 'requests' library, I found that I can perform the GET request and actually get a 200 status OK back. However, when using the response.json() call, the program hangs with no error and no output.</p>
<p dir="auto">If I run the same requests in python3 on my desktop environment, it all works.</p>
<p dir="auto">Here's where I got to:</p>
<pre><code class="language-python">import os, sys, io
import M5
from M5 import *
import network
import requests

title0 = None
statTitle = None
resTitle = None
stat = None
res = None
# http_req = None
wlan = None


status = None

def setup():
  global title0, statTitle, resTitle, stat, res, http_req, wlan, status

  M5.begin()
  Widgets.fillScreen(0x222222)
  title0 = Widgets.Title("Powermonitor", 3, 0xffffff, 0x0000FF, Widgets.FONTS.DejaVu18)
  statTitle = Widgets.Label("Status:", 2, 28, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  resTitle = Widgets.Label("Response:", 2, 57, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  stat = Widgets.Label("...", 110, 29, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  res = Widgets.Label("...", 111, 57, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)

  stat.setText(str('Fetching'))
  http_req = requests.get('http://192.168.10.22/api/v1/data')
  status = http_req.status_code
  stat.setText(str(status))
  print(str(http_req.status_code))
  print(str(http_req.reason))
  print(str(http_req.encoding))
  # print(str(http_req.raw))
  # print(str(http_req.text()))
  data = http_req.json()
  print(str(data))
  # print(str(http_req.json()))
  # http_req.close()
  # print(dir(responseJson))
  # print(responseJson())
  # res.setText(str(http_req.json()))


def loop():
  global title0, statTitle, resTitle, stat, res, http_req, wlan, status
  M5.update()


if __name__ == '__main__':
  try:
    setup()
    while True:
      loop()
  except (Exception, KeyboardInterrupt) as e:
    try:
      from utility import print_error_msg
      print_error_msg(e)
    except ImportError:
      print("please update to latest firmware")```</code></pre>
]]></description><link>https://community.m5stack.com/topic/6121/uiflow-2-0-1-http-get-and-parse-json</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 04:07:51 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6121.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Feb 2024 13:08:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UIFlow 2.0.1 HTTP GET and parse JSON on Wed, 21 Feb 2024 16:29:51 GMT]]></title><description><![CDATA[<p dir="auto">Yes, the endpoint responds almost instantly. Also the status code immediately comes back as as '200'.</p>
]]></description><link>https://community.m5stack.com/post/23989</link><guid isPermaLink="true">https://community.m5stack.com/post/23989</guid><dc:creator><![CDATA[streammyevent]]></dc:creator><pubDate>Wed, 21 Feb 2024 16:29:51 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow 2.0.1 HTTP GET and parse JSON on Wed, 21 Feb 2024 15:28:09 GMT]]></title><description><![CDATA[<p dir="auto">Are you sure its hanging and not taking ages to get a response?</p>
]]></description><link>https://community.m5stack.com/post/23987</link><guid isPermaLink="true">https://community.m5stack.com/post/23987</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Wed, 21 Feb 2024 15:28:09 GMT</pubDate></item></channel></rss>