-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
22 lines (17 loc) · 700 Bytes
/
server.py
File metadata and controls
22 lines (17 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from http.server import BaseHTTPRequestHandler, HTTPServer
class MyServer(BaseHTTPRequestHandler):
def _set_response(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
print("hola desde el get")
if "/sensor1_temp" in self.path:
sensor1_temp = self.path.split("=")[1]
print("La temperatura es {}".format(sensor1_temp))
self._set_response()
self.wfile.write("Hola este es mi super server. GET request for {}".format(self.path).encode('utf-8'))
port=8080
server_address = ('',port)
httpd = HTTPServer(server_address,MyServer)
httpd.serve_forever()