MQTT smart home web interface
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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