Follow these steps to learn how to create a web handler module:
- Run the following lines of code in the REPL:
>>> from netcheck import wait_for_networking >>> import socket >>> >>> HTTP_PORT = 80 >>> TCP_BACKLOG = 0 >>> BASE_TEMPLATE = """\ ... <!DOCTYPE HTML> ... <html lang="en"> ... <head> ... <title>MicroPython</title> ... <meta charset="UTF-8"> ... <link rel="icon" href="data:,"> ... <meta name="viewport" content="width=device-width"> ... </head> ... <body> ... %s ... </body> ... </html> ... """ >>>
- We have created a variable called BASE_TEMPLATE that will act as a generic template. Now, we can fill its body tag with any content we desire. The following block of code defines socket_listen, which does the initial socket ...