Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- with open ("config.json") as f:
- config = json.load(f)
- def do_connect():
- import network
- wlan = network.WLAN(network.STA_IF)
- wlan.active(True)
- if not wlan.isconnected():
- print('connecting to network...')
- wlan.connect(config["ssid"], config["ssid_password"])
- while not wlan.isconnected():
- pass
- print('network config:', wlan.ifconfig())
- def getAPI():
- import urequests
- response = urequests.get("http://api.openweathermap.org/data/2.5/weather?id={yourAPIkey}&lang=hu&units=metric")
- data = (response.json())
- w = data["weather"][0]
- print (w)
- response.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement