All sensors sending to server via http
Dependencies: C12832 CCS811 MMA7660 Sht31 TSL2561 mbed-http vl53l0x_api
Fork of HTTP-Python-Demo by
Diff: working/server_working.py
- Revision:
- 0:c5b042cf8162
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/working/server_working.py Tue Nov 14 14:26:53 2017 -0600
@@ -0,0 +1,43 @@
+from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
+import SocketServer
+import socket
+
+class MyHandler(BaseHTTPRequestHandler):
+
+ # HTTP REQUESTS HERE
+
+ def do_POST(self):
+ content = b"POST: Hello, Mbed!"
+ self.send_response(200)
+ self.send_header('Content-type', 'text/plain')
+ self.send_header('Content-Length', len(content))
+ self.end_headers()
+ self.wfile.write(content)
+ return
+
+ def do_GET(self):
+ content = b"GET: Hello, Mbed!"
+ self.send_response(200)
+ self.send_header('Content-type', 'text/plain')
+ self.send_header('Content-Length', len(content))
+ self.end_headers()
+ self.wfile.write(content)
+ return
+
+ def do_PUT(self):
+ content = b"PUT: Hello, Mbed!"
+ self.send_response(200)
+ self.send_header('Content-type', 'text/plain')
+ self.send_header('Content-Length', len(content))
+ self.end_headers()
+ self.wfile.write(content)
+ return
+
+def run():
+ httpd = HTTPServer(('', 8080), MyHandler)
+ print "HTTP server running on port 8080"
+ print "Your IP address is: ", socket.gethostbyname(socket.gethostname())
+ httpd.serve_forever()
+
+if __name__ == '__main__':
+ run()
