Skip to content

Commit 9f60024

Browse files
committed
Go serverless and make user wait for data to hit
1 parent 3a12112 commit 9f60024

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

WeatherStationCoreLink/main.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,8 @@ def looprequest():
146146
while True:
147147
data = looprequest()
148148
if data:
149-
if (time.time()-lastSentToServerTime) > int(os.environ.get('serverSendFrequency', 60)): #Send the server a reading every minute
150-
try:
151-
requestPayload = urllib.parse.urlencode(data)
152-
request = urllib.request.Request("https://" + str(os.environ.get('uploadUrl', '')) + "?" + str(requestPayload))
153-
with urllib.request.urlopen(request) as response:
154-
responseText = response.read().decode('utf-8')
155-
requestParsedResponse = json.loads(responseText)
156-
if requestParsedResponse["success"] is not True:
157-
log("[ERROR] Couldn't upload the data online - server rejected with " + str(requestParsedResponse["message"]) + " | " + str(response))
158-
else:
159-
lastSentToServerTime = time.time()
160-
log("[SUCCESS] Sent Data to WebServer")
161-
except Exception as e:
162-
log("[ERROR] Couldn't upload data online " + str(e))
149+
#if (time.time()-lastSentToServerTime) > int(os.environ.get('serverSendFrequency', 60)): #Send the server a reading every minute
150+
#Not currently uploading anything to any servers because it makes more sense to go serverless
163151
try:
164152
pusher_client.trigger('PSCWeatherDataLive', 'PSCWeatherDataLiveNEWReading', {'message': {'reading': data}})
165153
log("[SUCCESS] Sent Data to Pusher.com")

0 commit comments

Comments
 (0)