-
-
Save eydam-prototyping/3160fa5ec03f5c3349b5ab87a2bbf944 to your computer and use it in GitHub Desktop.
main.py v3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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