Last active
February 7, 2021 01:29
-
-
Save Neradoc/e807b8777b65900c700727f14367ada7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wifi | |
import ssl | |
import socketpool | |
import adafruit_requests | |
from secrets import secrets | |
print("WIFI: Connecting") | |
#wifi.radio.start_scanning_networks() | |
wifi.radio.connect(secrets['ssid'],secrets['password']) | |
#wifi.radio.stop_scanning_networks() | |
print("WIFI: " + str(wifi.radio.ipv4_address)) | |
# setting up sockets and request | |
pool = socketpool.SocketPool(wifi.radio) | |
sslc = ssl.create_default_context() | |
requests = adafruit_requests.Session(pool, sslc) | |
url = "https://httpbin.org/get" | |
print(f"getting {url} (twice)") | |
response = requests.get(url) | |
print(f"{response.status_code}, texte: {response.text}") | |
response = requests.get(url) | |
jason = response.json() | |
print(f"{response.status_code}, User Agent: {jason['headers']['User-Agent']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment