Skip to content

Commit 9245308

Browse files
authored
Add example for microcontrollers
1 parent 5c78e50 commit 9245308

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

examples/pastebin_simpletest.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
21
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney for Adafruit Industries
32
#
43
# SPDX-License-Identifier: Unlicense
4+
5+
import ssl
6+
import socket
7+
import adafruit_requests as requests
8+
from adafruit_pastebin.pastebin import PasteBin, ExpirationSetting, PrivacySetting
9+
10+
try:
11+
from secrets import secrets
12+
except ImportError:
13+
print("Please place your auth/dev key in a secrets.py file!")
14+
raise
15+
16+
wifi.radio.connect(secrets["ssid"], secrets["password"])
17+
pool = socketpool.SocketPool(wifi.radio)
18+
session = adafruit_requests.Session(pool, ssl.create_default_context())
19+
20+
auth_key = secrets["auth_key"]
21+
22+
pastebin = PasteBin(session, auth_key)
23+
paste_url = pastebin.paste(
24+
"This is a test paste!",
25+
name="My Test Paste",
26+
expiration=ExpirationSetting.ONE_DAY,
27+
privacy=PrivacySetting.UNLISTED,
28+
)
29+
print(paste_url)

0 commit comments

Comments
 (0)