tempserver.py – Server side for temperature measurement

#! /usr/bin/python3

import socketserver
import pymysql

class MyUDPHandler(socketserver.BaseRequestHandler):
    def handle(self):
        data = self.request[0].strip()
        socket = self.request[1]

#Write temperature on file
        client =  self.client_address[0]
        filename = '/tmp/' + client
        f = open(filename, 'w')

if __name__ == "__main__":
    HOST, PORT = "", 3000
    server = socketserver.UDPServer((HOST, PORT), MyUDPHandler)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>