Advertisement
Kenya-West

Untitled

Jul 21st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import sys
  2. from time import sleep
  3. import json
  4. import http.client, urllib.parse
  5. import re
  6. import requests
  7.  
  8.  
  9. while True:
  10. try:
  11. params = urllib.parse.urlencode({'uid': 1, 'temperature': 36.6})
  12. headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
  13. conn = http.client.HTTPConnection("137.117.173.220")
  14. conn.request("POST", "3000/sendSensorData", params, headers)
  15. response = conn.getresponse()
  16. print(response.status, response.reason)
  17. data = response.read()
  18. conn.close()
  19. except Exception as e:
  20. print("EXC", e)
  21. pass
  22. sleep(0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement