pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

HTTP

Example

GET method

from m5stack import *
from m5ui import *
from uiflow import *
import urequests
setScreenColor(0x222222)

try:
  req = urequests.request(method='GET', url='https://httpbin.org/get', headers={'Accept':'application/json'})
  print((str('Status: ') + str((req.status_code))))
  print(req.text)
  gc.collect()
  req.close()
except:
  print((str('Status: ') + str((req.status_code))))
  print('Fail')

POST method

from m5stack import *
from m5ui import *
from uiflow import *
import urequests
from libs.json_py import *
setScreenColor(0x222222)

try:
  req = urequests.request(method='POST', url='https://httpbin.org/post',json={'Payload':(py_2_json({'msg':'hello'}))}, headers={'Content-Type':'application/json'})
  print((str('Status: ') + str((req.status_code))))
  print(req.text)
  gc.collect()
  req.close()
except:
  print((str('Status: ') + str((req.status_code))))
  print('Fail')

API

try:
  req = urequests.request(method='GET', url='https://httpbin.org/get', headers={'Accept':'application/json'})
  print((str('Status: ') + str((req.status_code))))
  print(req.text)
  gc.collect()
  req.close()
except:
  print((str('Status: ') + str((req.status_code))))
  print('Fail')
  • Create HTTP requests, methods support GET, POST, DELET, PUT, PATCH.
print(req.status_code)
  • Return status code
print(req.text)
  • Getting the returned request data
On This Page