Skip to content

Instantly share code, notes, and snippets.

@eydam-prototyping
Last active February 16, 2021 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eydam-prototyping/3160fa5ec03f5c3349b5ab87a2bbf944 to your computer and use it in GitHub Desktop.
Save eydam-prototyping/3160fa5ec03f5c3349b5ab87a2bbf944 to your computer and use it in GitHub Desktop.
main.py v3
import network
import time
import ep_logging
import ep_http
import ep_file_server
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
# Set DHCP host name to recognize the device in your router
wlan.config(dhcp_hostname="Heater")
# Replace your SSID and password
wlan.connect("<SSID>", "<password>")
while not wlan.isconnected():
time.sleep(1)
logger = ep_logging.colored_logger(appname="main")
logger.notice("WiFi connected")
logger_http = ep_logging.colored_logger(appname="http")
fs = ep_file_server.file_server(
html_dir="/html/",
default_file="index.html",
logger=logger_http
)
routes = [
("^(.*)$", lambda sock, req: fs.serve(sock, req)), # every route is forwarded to file server
]
http_server = ep_http.http_server(routes=routes, micropython_optimize=True, logger=logger_http)
http_server.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment