MQTT smart home web interface
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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()