Skip to content

Commit

Permalink
Merge pull request #148 from AccelerationConsortium/pymongo
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbaird authored Feb 27, 2025
2 parents 97fd17c + a15b5e3 commit 7a648c7
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 683 deletions.
17 changes: 14 additions & 3 deletions docs/courses/hello-world/1.5-data-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,33 @@ For the purposes of this tutorial, we have set up a free-tier test database thro
SSID = "Enter your SSID here"
PASSWORD = "Enter your WiFi password here"
COURSE_ID = "sassy-robin"
ATLAS_URI = "https://bbwl4guz6jqors4xcnnll6sucq0ttapg.lambda-url.us-east-2.on.aws/"
LAMBDA_FUNCTION_URL = (
"https://bbwl4guz6jqors4xcnnll6sucq0ttapg.lambda-url.us-east-2.on.aws/"
)
```

`write_mongodb.py`
```python
import json

import requests
from my_secrets import ATLAS_URI, COURSE_ID, PASSWORD, SSID
from my_secrets import LAMBDA_FUNCTION_URL, COURSE_ID, PASSWORD, SSID
from netman import connectWiFi

connectWiFi(SSID, PASSWORD, country="US")

document = {"course_id": COURSE_ID}

response = requests.post(ATLAS_URI, json=document)
DATABASE_NAME = "test-db"
COLLECTION_NAME = "write-to-me"

payload = {
"database": DATABASE_NAME,
"collection": COLLECTION_NAME,
"document": document,
}

response = requests.post(LAMBDA_FUNCTION_URL, json=payload)

if response.status_code == 200:
response_data = response.json()
Expand Down
Loading

0 comments on commit 7a648c7

Please sign in to comment.