How it works...
One of the first things that are defined in the script is the HTML template. This template will generate valid HTML5 web pages, which will render correctly on both mobiles and desktops.
The icon link tag is present to prevent web browsers from unnecessarily asking for favicon.ico files. The socket_listen function is called to bind and listen to the default HTTP port. The serve_requests function is then called and will endlessly serve all incoming HTTP requests. The start time of the web server is recorded in a variable called start. We will use this to calculate the server uptime for each request.
We call the accept method, which will block the code until a new request comes to the web server. Once we receive this new request, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access