import network
import time
import urequests
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('wifi_ssid', 'wifi_password')
while not wlan.isconnected():
print('... Connecting')
time.sleep(1)
print('Congratulations, You are connected')
print('Your IP address:', wlan.ifconfig()[0])
try:
astronauts = urequests.get("http://api.open-notify.org/astros.json").json()
print("Astronauts:", astronauts)
except OSError as e:
print("Connection error:", e)