Skip to content

Commit f215111

Browse files
committed
Tracking things
1 parent 547751b commit f215111

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

Pipfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ uvicorn = "*"
1010
uuid = "*"
1111
boto3 = "*"
1212
botocore = "*"
13+
pymongo = "*"
14+
requests = "*"
1315

1416
[dev-packages]
1517

1618
[requires]
17-
python_version = "3.9"
19+
python_version = "3.11"

app/main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
from fastapi.middleware.cors import CORSMiddleware
55
from typing import Optional
66
import string
7+
import pymongo
8+
import bson
9+
import requests
10+
import os
711
# import random
812
# import uuid
913

14+
MONGO_URI = os.getenv("RC_MONGO_URI")
15+
1016
app = FastAPI()
1117
origins = ['*']
1218
app.add_middleware(
@@ -22,3 +28,11 @@ def zone_apex():
2228
@app.get("/floors")
2329
def return_floors():
2430
return {"floors":[1, 2, 3, 4]}
31+
32+
@app.post("/temperature")
33+
def temperature(request: dict):
34+
client = pymongo.MongoClient(MONGO_URI)
35+
db = client["building_data"]
36+
collection = db["temperature"]
37+
collection.insert_one(request)
38+
return {"message": "Temperature data received", "data": request}

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ uvicorn
44
uuid
55
boto3
66
botocore
7+
requests
8+
pymongo

0 commit comments

Comments
 (0)