Cover image for Build a Web Server Using a Raspberry Pi Pico W and Phew!

Video

Watch the associated video here:


Cover photo

Hello fellow robot makers! Have you ever given thought to building your own website using a Raspberry Pi Pico W, only to pause at the complicated steps or unsatisfactory results? If yes, let’s put a halt to that and present a superior alternative, a brilliant tool called Phew! In this blog post, we’ll guide on you on using this wonderful web server and templating engine ideally designed for the Raspberry Pi Pico W. So, let’s dive right into it!


The Phew! Web Server

Developed by Pimoroni for their Enviro products, Phew! was conceived for creating captive Wi-Fi’s hotspots and to provide an easy to use web interface when setting up the devices. This vital tool runs impeccably on Pico W’s and practically any other MicroPython board, however, it’s customised specifically for the Pico W. Besides offering a sturdy built-in web server, Phew! also provides incredible features such as logging and an intuitive templating system, aiming to make interactive websites building an effortless process.


The Magic of Templates

With Phew!, templates become a programmer’s best friend. They allow you to integrate data from your program dynamically into the web page. A straightforward concept, you merely embed the variable data within ‘squiggly brackets’ in the template and pass the variables while rendering the template. As a result, you can include the page title, content, or virtually any program data using templates making your development process a breeze!

E.g.

<html>
    <head>
        <title>{{ title }}</title>
    </head>
    <body>
        <h1>{{ title }}</h1>
        <p>{{ content }}</p>
    </body>
</html>

In this example, the title and content are variables that are passed to the template when rendering it. The template engine replaces the variables with the actual values, resulting in a complete web page.


Multi-Part Web Pages

One of the most influential features within Phew! is its ability to handle multipart web pages. You can essentially construct different portions of your pages while leaving it to Phew! to compile the complete page drawing from these fragments. This convenient feature facilitates the reusability of common parts like the heading, footer, or navigation across different pages leading to consistent and easy web page development.


Effective Logging

Logging is an integral aspect of any program, more so for embedded systems. Phew! provides a detailed logging feature that stamps the type, time, and sequence of the messages, offering a fundamental debugging feature. With four varied levels, debug, info, warn, and error, logging caters to different programming and diagnostic needs, saving the contents of your messages to your system, especially beneficial for autonomous functioning systems.


Creating Forms

A pivotal feature, forms, enable the capturing of data from the user. Phew! provides a simplistic method to create forms and capture this data through the request object. Once captured, the request object allows you to modify and manipulate data to fit your control requirements. Need it to control flashing lights or send data off to an MQTT server? Phew! has you covered.

Phew! represents a significant breakthrough for Raspberry Pi Pico W users, offering an extensive set of useful features crafted to cater to all your web server needs. So, the next time you find yourself struggling with complicated steps or unsatisfactory results, remember there’s a simple and effective tool right at your fingertips.

Explore Phew! today and revolutionize your web server building experience with a little help from Raspberry Pi Pico W.

Visit the Phew! GitHub repository https://www.github.com/pimoroni/phew



Did you find this content useful?


If you found this high quality content useful please consider supporting my work, so I can continue to create more content for you.

I give away all my content for free: Weekly video content on YouTube, 3d Printable designs, Programs and Code, Reviews and Project write-ups, but 98% of visitors don't give back, they simply read/watch, download and go. If everyone who reads or watches my content, who likes it, helps fund it just a little, my future would be more secure for years to come. A price of a cup of coffee is all I ask.

There are a couple of ways you can support my work financially:


If you can't afford to provide any financial support, you can also help me grow my influence by doing the following:


Thank you again for your support and helping me grow my hobby into a business I can sustain.
- Kevin McAleer