🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How can we use HTTP request with UIFlow 2.0?

    UiFlow 2.0
    4
    5
    3.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kotobuki
      last edited by

      Hi,

      I'm trying to implement an HTTP client on AtomS3 Lite with UIFlow 2.0. I have implemented on ATOM LITE with UIFlow 1.0 as follows:

      https://github.com/kotobuki/Toolkit-for-Collaborative-XR/blob/main/examples/uiflow/update_attribute_atom.png

      My questions are as follows:

      • When should we use HTTP close, right after an HTTP request block or after handling a response?
      • What is equivalent to Get Data in UIFlow 1.0, get content or get text?

      It would be much appreciated if you give me advice regarding this topic.

      Thank you very much in advance,
      Shigeru

      1 Reply Last reply Reply Quote 0
      • K
        kotobuki
        last edited by

        Hi,

        I found that the following code works as I expected. I want to share for your reference until official examples are provided.

        0_1698209398752_uiflow2_block_1698209308543.png

        Thanks,
        Shigeru

        1 Reply Last reply Reply Quote 1
        • P
          Pixellord
          last edited by

          Hi Shigeru,

          Can you share how do you install the "urequests" module?

          I downloaded from the link below and copied to libs/
          https://github.com/m5stack/M5Stack_MicroPython/blob/master/MicroPython_BUILD/components/micropython/esp32/modules/urequests.py

          but I got the following error:
          Traceback (most recent call last):
          File "main.py", line 105, in <module>
          File "main.py", line 92, in loop
          File "/flash/libs/urequests.py", line 112, in get
          File "/flash/libs/urequests.py", line 97, in request
          NotImplementedError: Redirects not yet supported

          Thanks

          1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3
            last edited by

            Http close is used at the end to terminate HTTP request sessions.

            I'm trying to work on logging and documenting the functions but its slow going.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • MadeFLM
              MadeFL
              last edited by

              Hi,

              I am new, but I have been poking around since I experienced the urequests library not found error.

              I REPL'd into my Core3,, and sure enough, it wasn't there, but there was one called requests.

              I did some poker with the code in UiFlow and read many Google answers, but I managed to get it to work. I ended up with the HTTP request in a code block.

              http_req = requests.request(
              method='POST',
              url='http://192.168.1.51/json/state',
              headers={'Content-Type':'application/json'},
              data='{"on":true,"bri":255, "v":true, "seg":{"fx":"r", "pal":"r"}}'
              )
              http_req.close()

              It seemed to work for me, but I would prefer to get it working correctly.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post