Skip to content

Enabling/wipy-urllib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

wipy-urllib

To be completed, see urequests hereunder

urequests

First version of urequests for micropython, minor bug-fixes to work with Enabling's Cloud Channels Based on https://github.com/lucien2k/wipy-urllib

Supports:

  • SSL
  • Cookies
  • Basic Auth
  • Custom HTTP Headers
  • GET, POST, PUT, DELETE, OPTIONS, HEAD
  • JSON payloads (experimental)

##Use it Upload urequests.py on WiPy (FTP) in /flash/lib directory

Python usage:

import urequests

''' Your cloud-channel is defined here:'''
url = "https://api.enco.io/platform/cloudchannels/1.0.0/cc/861ec263-41e7-4d35-9d6c-3c17889b106c"

''' The payload you defined in your CloudChannel interface, in this case a simple integer called 'sensor':
 {"type":"object","properties":{"Sensor":{"type":"integer"}},"title":"sensor"}'''
payload = {"Sensor": 1}

''' your auth bearer here, Content-Type must be set to 'Application/json' '''
myheaders = {
    "Authorization": "Bearer 38dfbef7900f75cadbae76e33f91363f",
    "Content-Type": "application/json"
    }
    
''' Actual call, returns an URLOpener object '''
response = urequests.urlopen(url, "POST", {}, payload, headers=myheaders)

''' URLOpener attributes '''
response.text
response.headers
response.url
response.status_code

Similar interface to http://docs.python-requests.org/en/latest/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%