Hi Kevin Good intro to web serving on the pico. I think your final bug comes from the fact that there is no default.html file on the pico (see the directory listing on the lower left at 1:14:22). unless I've misunderstood your coding whether the username/password pair is correct or not default.html is called with different text. As the file is not on the pico this will cause a problem. It would have been nice to get a "File not found" message somewhere. As far as I can tell you never uploaded it to the pico but all the other .html files are. Hope this helps Ian
@@kevinmcaleer28 You're welcome. I did a bit of digging around and discovered that in earlier versions of Micropython instead of getting "OSError: [Errno 2] ENOENT" there was a message "could not open file 'xxxx.yyy' for reading". This has since been "improved" to the current cryptic version. Love the "Cube" model. Might be interesting to re-jig it for a Pi Zero W 2 and see if there is a port of NeXTStep to run on it 🙂 Glad I could be of some help
Thank you so much. I am a programmer (very old guy here) and was struggling to much with thonny (linux with arm64 here, I hate Microsoft and Apple, LOL). I finally managed to use the Thonny version 4, was able to install upip and then the IDE is ok, there was so much disconnections with Thonny 3... Your video is clear and very instructive, I found a lot of answers. Thank you Kevin.
@Kevin, you forget to upload the 'default.html' to Pico for the "Demo7 - Form" chapter @1:02:45. The render_template fails to render the page when the POST method for the '/login' url wants to send data to the 'default.html' (since it is missing).
Am interested if this could be also used to setup the PicoW as an Access point so that i could use the PHEW web-server to control device such as a robot via direct Wifi connection to the PicoW? That way students could learn about & use the robot without needing to use a router
Hint: the render_template() is a generator. You must return a Response object, where the body could be a str or a generator. Instead of return render_template(...) you do return Response(render_template(...), status=200, {"Content-Type": "text/html"})
Very cool. I'm thinking I'll try this PHEW out but I would like to see a follow up video that shows it working and what issues to look out for regarding what went wrong. Thank you btw for producing these. I know they take a lot of work.
Thanks Tom - Ian Crowe spotted my mistake - I hadn't uploaded the default.html file from the repository. I tried after the show and it of course worked fine then!
I'm really glad you introduced me to Phew, it's allowed me to create a bunch of nifty Pico projects lately! From a web interface for my wifi enabled alarm-clock and room messaging device, to a mobile Access Point, that hosts a guestbook or group email signup, simple message room, and info or coordination page for use at "activism" events. heh I did have to fix a couple bugs within phew's code, nothing too major, tho I'm still trying to figure out what's causing an odd error: "need more than 0 values to unpack" or similar, which sometimes crash the server.. Phew doesn't seem to give me enough info to figure it out on my own.
Great overview, Kevin, well worth a cup of coffee. I'm sure you found your missing default.html file. The framework is very similar to Flask which I have been using for a few months. And this is so much simpler and yet more feature rich than the standard web package.
hello, thanck you for your tutorial. really helpful, just a question, how can we add css or other file like js? in microdot we can add it with a route.
Hi Kevin, Is it possible to use Phew to stream sensor data similar to the tutorial you did with the MPU9250/6050? - Can we call render_templates in a loop to update the index.html variables?
Yes - the way you would do this is to change a json file and have the page poll that file via a JavaScript script using jQuery. I’ll add that to my blog ideas page as it’s a good thing to cover.
@@kevinmcaleer28 Thanks - I ended up figuring out a similar solution. I created a new endpoint, then polled that and returned a text string. Might not be best practice, but its functional.
Hi Kevin, thanks for the interesting content you create . I have a question : is it possible to run a phew server and a mqtt client at the same time on the same pico w ? I want to build a module consisting of a pico w and a PCA9685 providing both a mqtt as well as an api interface. I build the mqtt, and the api on seperate PICO's but i run into probblemns when trying to run both on the same device. Would be a nice project.
I am trying to send a a JSON object from the Phew server to a java script function, How does one send JSON in a request or Template, I tried and it failed, Great instruction video, it took me 90% of the way with PHEW. Thanks in advance for any help!
Its kind of the other way round - the Javascript function should make a call to an API endpoint, which is just a route for phew to provide data via. does that make sense?
I wanted to create a web config page for the pico based device. Basically updating the ssid/password for the wifi during run time. View log event of certain pin. For that the tutorial was good. Just out of curiosity does this phew server has some middleware request forwarding for every request for basically auth handling ?
Thats a great spot Peter - you'll need to sync the real time clock with a network time provider - check the code in big mouth billy bass, as I do that just after connecting to wifi github.com/kevinmcaleer/bigmouth_wifi/blob/main/billy.py line 62 to 104
Hi Kevin, I did connect the ordinary way to connect to my wifi without any problems but, if i use the Phew line, i got only get "got ip address" any ideas how this is happening?
I noticed to install phew, you typed microphython-phew as the name of the file to install? does that mean this wont work on CircuitPython? and only with MicroPhython ? (Phew?)
@@compubyte2010 I think you’ll still type micropython-phew when installing it. It’s compatible with both. It’s just that the name ‘phew’ was already taken.
Would I be able to use a Raspberry Pi Pico W as a Backup DNS Server to keep my Internet Online if my Raspberry Pi 4 goes Offline? My problem is my Router makes me put in two DNS Addresses so I set them both as the PiHole DNS Addresses I've tried setting the Secondary DNS as Google's DNS but if I do that and turn off my Raspberry Pi 4 it doesn't allow me to connect to the Internet unless I turn the Raspberry Pi 4 back on and with the Prices of Raspberry Pi 4 and even the Raspberry Pi 3 right now I don't really want to spend that amount of money on another one right now if I don't have to?
hi Kevin if i wanna put a button on the web to trigger a pin on the pico w using phew please ad want to know if its possible if the button show off its red and when pressed it change to on and button turns green ?
@@kevinmcaleer28 The latest 'W' one, the one that jokingly says comes bundled with upip! rp2-pico-w-20221123-unstable-v1.19.1-713-g7fe7c55bb.uf2 I am pretty sure that I am using a Pico W, I have 3 'normal' ones and 4 'W' ones, and Phew is working fine on one of them. Ha, I let the cat out of the bag! Yes, thank you very much, Phew is working fine. It took me a long to figure out upip, then I found a video yesterday that showed me how to install it via Thonny. So thanks for the reply and a great video. Oh, and thanks to your code, I was able to solve another couple of problems, most of the videos up to now, only display 1 webpage, now thanks to the Nav bar I can display as many as I want, also I was able to figure out how to make a working hyperlink. If you have a minute, when I installed some other libraries via Demo1, they installed into a folder called .frozen. Any ideas why they installed there and not .lib?
The latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
Hello Bro, Im from Indonesia. Amazing Phew... I have been try flask, but i think phew more simple .. I Try your tutorial from demo 1 until 3 success. in demo 4 no error Sir, But no respon on web and error.. please help me :)
If an app is created with the intent of giving the hardware to an end user with a different LAN, how would they get their wifi credentials in without using the development environment?
You can create a captive portal so you connect to that device and it can scan for Wi-Fi hotspots and then let’s you enter the password and stores it to flash
Q - Hi Kevin from Vancouver Island B.C. Canada - any pointers to where I can get programming doc for PHEW? Old farts like me need written instructions! Thanks
Yes - Ian spotted it, I hadn't uploaded the default.html which is a template file I created but hadn't copied to the Pico. default.html is file with just three lines that imports the header, footer and content
Hi Pranav, the latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
your tutorial doesn't work as the version of Micropython that Thony 4.0.1 installs which is the same as on the Micropython website v1.19.1-782-g699477d12 on 2022-12-20 Raspberry Pi Pico W with RP2040 doesn't have upip module after trying to manually copy upip, i eventully found there is a package manager in Thony and tried all of the 3 upip options availble. Only the first one worked without an error, but it installs phew to ./frozen folder which then isn't visible i will manually try download phew next and see if i can continue
The latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
I don't have any benchmarks, other than the page count, and the number of visit I track via Cloudflare. I think it only accepts a single connection at a time, but handles them so fast its within any browsers timeout.
Yeah - he fell over board rather quickly after he (for no reason what-so-ever) suddenly jumped into VS - code. Continuing without correcting the error was the biggest no-no however. But everything was nice and good until he fell out of the boat.
With my Raspberry Pi Zero, I was able to set a hostname before connecting to a network. Afterwards I was able to access the hosted web app with hostname.local which was very convenient. I can't find a way to get this behaviour on the pico. Although the wlan.config(essid=...)-method is - according to the documentation - only for setting the name of an access point, I tried in anyway, but it didn't work.
Hi Kevin
Good intro to web serving on the pico.
I think your final bug comes from the fact that there is no default.html file on the pico (see the directory listing on the lower left at 1:14:22).
unless I've misunderstood your coding whether the username/password pair is correct or not default.html is called with different text. As the file is not on the pico this will cause a problem. It would have been nice to get a "File not found" message somewhere.
As far as I can tell you never uploaded it to the pico but all the other .html files are.
Hope this helps
Ian
Ian - I think you’ve nailed it! I didn’t copy that over did I and it’s right there in the repository. Great spot, and thanks!
@@kevinmcaleer28 You're welcome.
I did a bit of digging around and discovered that in earlier versions of Micropython instead of getting "OSError: [Errno 2] ENOENT" there was a message "could not open file 'xxxx.yyy' for reading".
This has since been "improved" to the current cryptic version.
Love the "Cube" model. Might be interesting to re-jig it for a Pi Zero W 2 and see if there is a port of NeXTStep to run on it 🙂
Glad I could be of some help
Phew! is an awesome HTML Server library. I saves you a lot of time. An Kevin did a great job explaining how to use it.
Thank you so much. I am a programmer (very old guy here) and was struggling to much with thonny (linux with arm64 here, I hate Microsoft and Apple, LOL). I finally managed to use the Thonny version 4, was able to install upip and then the IDE is ok, there was so much disconnections with Thonny 3... Your video is clear and very instructive, I found a lot of answers. Thank you Kevin.
@Kevin, you forget to upload the 'default.html' to Pico for the "Demo7 - Form" chapter @1:02:45. The render_template fails to render the page when the POST method for the '/login' url wants to send data to the 'default.html' (since it is missing).
Well spotted!!
Am interested if this could be also used to setup the PicoW as an Access point so that i could use the PHEW web-server to control device such as a robot via direct Wifi connection to the PicoW?
That way students could learn about & use the robot without needing to use a router
Hi Kevin!! Thanks for this amazing tutorial!! Great Job
Hint: the render_template() is a generator. You must return a Response object, where the body could be a str or a generator. Instead of return render_template(...) you do return Response(render_template(...), status=200, {"Content-Type": "text/html"})
Takk!
Thank you! I really appreciate your support
Amazing job Kevin! Greetings from Poland!
Thanks
This Framework is amazing!! Thanks Pimoroni!! And Thank you Kevin to make this tutorial!! 😁👍cheers!!
Very cool. I'm thinking I'll try this PHEW out but I would like to see a follow up video that shows it working and what issues to look out for regarding what went wrong.
Thank you btw for producing these. I know they take a lot of work.
Thanks Tom - Ian Crowe spotted my mistake - I hadn't uploaded the default.html file from the repository. I tried after the show and it of course worked fine then!
@@kevinmcaleer28 Thank you I SO know how that goes. No worries. Will you have a complete write up on this on your site? Thank you for your note back.
I'm really glad you introduced me to Phew, it's allowed me to create a bunch of nifty Pico projects lately! From a web interface for my wifi enabled alarm-clock and room messaging device, to a mobile Access Point, that hosts a guestbook or group email signup, simple message room, and info or coordination page for use at "activism" events. heh
I did have to fix a couple bugs within phew's code, nothing too major, tho I'm still trying to figure out what's causing an odd error: "need more than 0 values to unpack" or similar, which sometimes crash the server.. Phew doesn't seem to give me enough info to figure it out on my own.
Great overview, Kevin, well worth a cup of coffee. I'm sure you found your missing default.html file. The framework is very similar to Flask which I have been using for a few months. And this is so much simpler and yet more feature rich than the standard web package.
Thanks for the coffee too!
Finally!!! A small version kind of Flask. Pretty cool!!!
Kevin, thank you a lot! great stream!
hello, thanck you for your tutorial. really helpful, just a question, how can we add css or other file like js? in microdot we can add it with a route.
Hi Kevin, Is it possible to use Phew to stream sensor data similar to the tutorial you did with the MPU9250/6050? - Can we call render_templates in a loop to update the index.html variables?
Yes - the way you would do this is to change a json file and have the page poll that file via a JavaScript script using jQuery. I’ll add that to my blog ideas page as it’s a good thing to cover.
@@kevinmcaleer28 Thanks - I ended up figuring out a similar solution. I created a new endpoint, then polled that and returned a text string. Might not be best practice, but its functional.
Hi Kevin, thanks for the interesting content you create .
I have a question : is it possible to run a phew server and a mqtt client at the same time on the same pico w ? I want to build a module consisting of a pico w and a PCA9685 providing both a mqtt as well as an api interface. I build the mqtt, and the api on seperate PICO's but i run into probblemns when trying to run both on the same device.
Would be a nice project.
Wow! Pico W is a great thging!
I am trying to send a a JSON object from the Phew server to a java script function, How does one send JSON in a request or Template, I tried and it failed,
Great instruction video, it took me 90% of the way with PHEW. Thanks in advance for any help!
Its kind of the other way round - the Javascript function should make a call to an API endpoint, which is just a route for phew to provide data via. does that make sense?
Have a read of this article: www.kevsrobots.com/blog/simple-robot-arm.html#the-web-ui
I wanted to create a web config page for the pico based device. Basically updating the ssid/password for the wifi during run time.
View log event of certain pin. For that the tutorial was good. Just out of curiosity does this phew server has some middleware request forwarding for every request for basically auth handling ?
I notice your logfiles have the correct timestamp, when I run the demos with logging, the timestamp starts at Jan 1st midnight 2021?
Thats a great spot Peter - you'll need to sync the real time clock with a network time provider - check the code in big mouth billy bass, as I do that just after connecting to wifi github.com/kevinmcaleer/bigmouth_wifi/blob/main/billy.py line 62 to 104
@@kevinmcaleer28 , cheers Kevin, now syncs the time correctly
Great job Kevin!
Thanks Kevin!
@@kevinmcaleer28 welcome Kevin love your work!
Thanx mate. You explained well.
Hi Kevin,
I did connect the ordinary way to connect to my wifi without any problems but, if i use the Phew line, i got only get "got ip address" any ideas how this is happening?
Kevin, Can you copy the PHEW directory onto another Pico rather than doing the uPip install?
Absolutely - you can download it and copy it across using Thonny, or even install via the Thonny package manager
I noticed to install phew, you typed microphython-phew as the name of the file to install?
does that mean this wont work on CircuitPython? and only with MicroPhython ? (Phew?)
I asked Pimoroni and they think Phew will work fine on CircuitPython
@@kevinmcaleer28 SO would I type CircuitPython-phew within CircuitPython? or do I still type Micophython-phew within circuitpython?
@@compubyte2010 I think you’ll still type micropython-phew when installing it. It’s compatible with both. It’s just that the name ‘phew’ was already taken.
Would I be able to use a Raspberry Pi Pico W as a Backup DNS Server to keep my Internet Online if my Raspberry Pi 4 goes Offline? My problem is my Router makes me put in two DNS Addresses so I set them both as the PiHole DNS Addresses I've tried setting the Secondary DNS as Google's DNS but if I do that and turn off my Raspberry Pi 4 it doesn't allow me to connect to the Internet unless I turn the Raspberry Pi 4 back on and with the Prices of Raspberry Pi 4 and even the Raspberry Pi 3 right now I don't really want to spend that amount of money on another one right now if I don't have to?
hi Kevin if i wanna put a button on the web to trigger a pin on the pico w using phew please ad want to know if its possible if the button show off its red and when pressed it change to on and button turns green ?
Totally possible
I am a beginner in Raspberrys, and tried the install process. It says "upip not found" - I am lost. Are ther other things to be installed up front?
mpy replaced upip as the package manager
Hello, i tried to import upip but it just throw the error: ImportError: no module named 'upip'
Hi Gandalf, I have the same problem and have been unable to find a solution. Were you able to solve it, if so how?
What version of micropython are you using? upip does require the Pico W microcontroller as well as the version of MicroPython firmware for the Pico W
@@kevinmcaleer28 The latest 'W' one, the one that jokingly says comes bundled with upip!
rp2-pico-w-20221123-unstable-v1.19.1-713-g7fe7c55bb.uf2
I am pretty sure that I am using a Pico W, I have 3 'normal' ones and 4 'W' ones, and Phew is working fine on one of them.
Ha, I let the cat out of the bag! Yes, thank you very much, Phew is working fine. It took me a long to figure out upip, then I found a video yesterday that showed me how to install it via Thonny.
So thanks for the reply and a great video.
Oh, and thanks to your code, I was able to solve another couple of problems, most of the videos up to now, only display 1 webpage, now thanks to the Nav bar I can display as many as I want, also I was able to figure out how to make a working hyperlink.
If you have a minute, when I installed some other libraries via Demo1, they installed into a folder called .frozen. Any ideas why they installed there and not .lib?
The latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
closing body tag ?
Hello Bro,
Im from Indonesia.
Amazing Phew...
I have been try flask, but i think phew more simple ..
I Try your tutorial from demo 1 until 3 success. in demo 4 no error Sir, But no respon on web and error.. please help me :)
Interesting stuff thank you 👍
Thanks @Beni D! I’m still a bit frustrated the last demo didn’t work properly
If an app is created with the intent of giving the hardware to an end user with a different LAN, how would they get their wifi credentials in without using the development environment?
You can create a captive portal so you connect to that device and it can scan for Wi-Fi hotspots and then let’s you enter the password and stores it to flash
How to build a captive portal with MicroPython - the easiest way EVER!
th-cam.com/video/2Y42DSZpR0w/w-d-xo.html
Q - Hi Kevin from Vancouver Island B.C. Canada - any pointers to where I can get programming doc for PHEW? Old farts like me need written instructions! Thanks
Sure - check out GitHub.com/Pimoroni/phew
@@kevinmcaleer28 thanks Kevin!
upip no longer supported, need to use the mip library.
0:58 Are you sure it's not 'ukip'?
(Asking for my friend. His name is Nigel.)
Love your video
Kev, just in case you have not figured what the problem was - it's one of the "content =" statements, it looks like content = f"xxx", Cheers.
COOL stuff.
Did you manage to fix the code?
Yes - Ian spotted it, I hadn't uploaded the default.html which is a template file I created but hadn't copied to the Pico. default.html is file with just three lines that imports the header, footer and content
Hi this is Pranav, I am unable to use upip, when using the line import upip it is showing me a error - " ImportError: no module named 'upip' "
Hi Pranav, the latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
@@danahuff6823 Thank you so much that works perfectly. 😊😊😊
Great video, Thanks !
Where do I get Phew?
your tutorial doesn't work as the version of Micropython that Thony 4.0.1 installs which is the same as on the Micropython website v1.19.1-782-g699477d12 on 2022-12-20 Raspberry Pi Pico W with RP2040 doesn't have upip module
after trying to manually copy upip, i eventully found there is a package manager in Thony and tried all of the 3 upip options availble. Only the first one worked without an error, but it installs phew to ./frozen folder which then isn't visible
i will manually try download phew next and see if i can continue
ok back on track - i downloaded micropython-phew-0.0.3.tar.gz and used the Thony package manager to install it from my download folder.
The latest releases of Micropython have replaced "upip" with "mip". I have found I cannot install the latest version phew package the usual way without errors so I installed from the Pimoroni/phew github page and that works.
have you benchmarked how many clients can be accepted as a connection on the server on a single Pico?
I don't have any benchmarks, other than the page count, and the number of visit I track via Cloudflare. I think it only accepts a single connection at a time, but handles them so fast its within any browsers timeout.
@@kevinmcaleer28 I see, so it can be mostly to edit some settings, one family member of a house, probably can use it at a time.
Q is it phew pronounced "few", which would be the usual English, or "pew" as in church pew, which sounds strange here?
Jon says is Phew as in ‘phew that’s a relief’ and not as in pew ‘pew pew’ Han shot first
Cheers!
You were all over the place!
What do you mean?
Yeah - he fell over board rather quickly after he (for no reason what-so-ever) suddenly jumped into VS - code. Continuing without correcting the error was the biggest no-no however. But everything was nice and good until he fell out of the boat.
With my Raspberry Pi Zero, I was able to set a hostname before connecting to a network. Afterwards I was able to access the hosted web app with hostname.local which was very convenient. I can't find a way to get this behaviour on the pico. Although the wlan.config(essid=...)-method is - according to the documentation - only for setting the name of an access point, I tried in anyway, but it didn't work.
great video just i didnt learn nothing
Apollo 13 had enough problems as it was - contacting 'Huston' would not have helped at all.
I thought Al Gore invented the internet. 😜
I really enjoyed this video... Thank you Kevin.
As of Mar 3 2024 phew is math and stat app for insurance. Huh?
"a library housing basic mathematical and statistical formulae used in insurance."
Try this instead pypi.org/project/micropython-phew/
flask(Phew) in micropython! It's awesome!