I'm looking for a way to write a small python app (ubuntu) which will serve a simple webpage on port 80 for example but also will detect when someone load it (visits it). I want to raise a certain event upon visiting and execute another function which will send some information to an external device.
An yes, I'm new to python. I do have a script for just serving a page, but can't get a part into it to raise the event of visiting this page:
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Thank you for you help!)
p.s. In total it's a "physical" counter..so to say:) I have it all running on Raspberry Pi and want to light up leds upon visitors viewing the page.