This recipe will show you how we can take a lot of the code and logic involved in handling sockets, parsing HTTP request headers, and generating HTML, and bundle it all into a single Python module. Once we have it in one module, we can import this module and pass it our web handler, which will do all the heavy lifting for us.
You will find this recipe useful when you are creating projects that create a web-based application on your microcontroller and you want to get productive fast, without getting bogged down in all the low-level details of sockets and parsing HTTP headers.