MQTT smart home web interface
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

localtest.py 505B

12345678910111213141516171819
  1. #!/usr/bin/env python3
  2. # https://stackoverflow.com/a/52531444
  3. import http.server
  4. import socketserver
  5. PORT = 8080
  6. DIRECTORY = "lights"
  7. class Handler(http.server.SimpleHTTPRequestHandler):
  8. def __init__(self, *args, **kwargs):
  9. super().__init__(*args, directory=DIRECTORY, **kwargs)
  10. # https://stackoverflow.com/a/16641793
  11. socketserver.TCPServer.allow_reuse_address = True
  12. with socketserver.TCPServer(("", PORT), Handler) as httpd:
  13. print("serving at port", PORT)
  14. httpd.serve_forever()