Build your own web server using a Raspberry Pi Pico W using Phew!

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 101

  • @iancrowe8384
    @iancrowe8384 2 ปีที่แล้ว +11

    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
      @kevinmcaleer28  2 ปีที่แล้ว +2

      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!

    • @iancrowe8384
      @iancrowe8384 2 ปีที่แล้ว +4

      @@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

    • @aroldo1959
      @aroldo1959 7 หลายเดือนก่อน

      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.

  • @renobodyrenobody
    @renobodyrenobody ปีที่แล้ว +3

    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.

  • @IoTRepublic
    @IoTRepublic ปีที่แล้ว +4

    @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).

  • @Keeping_IT_Simple
    @Keeping_IT_Simple ปีที่แล้ว +2

    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

  • @cursoderobotica
    @cursoderobotica 2 ปีที่แล้ว +1

    Hi Kevin!! Thanks for this amazing tutorial!! Great Job

  • @deadeye1982a
    @deadeye1982a ปีที่แล้ว +6

    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"})

  • @OleBSrhus
    @OleBSrhus ปีที่แล้ว +1

    Takk!

    • @kevinmcaleer28
      @kevinmcaleer28  ปีที่แล้ว +1

      Thank you! I really appreciate your support

  • @coder_one
    @coder_one 2 ปีที่แล้ว +2

    Amazing job Kevin! Greetings from Poland!

  • @kyberzyler
    @kyberzyler 2 ปีที่แล้ว

    Thanks

  • @cursoderobotica
    @cursoderobotica 2 ปีที่แล้ว +1

    This Framework is amazing!! Thanks Pimoroni!! And Thank you Kevin to make this tutorial!! 😁👍cheers!!

  • @TomParish
    @TomParish 2 ปีที่แล้ว +3

    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.

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว +1

      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!

    • @TomParish
      @TomParish 2 ปีที่แล้ว

      @@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.

  • @NikoKun
    @NikoKun ปีที่แล้ว

    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.

  • @danahuff6823
    @danahuff6823 2 ปีที่แล้ว +1

    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.

  • @fvgoya
    @fvgoya ปีที่แล้ว

    Finally!!! A small version kind of Flask. Pretty cool!!!

  • @vynylPooh
    @vynylPooh 2 ปีที่แล้ว +1

    Kevin, thank you a lot! great stream!

  • @madeinfonddugarage5988
    @madeinfonddugarage5988 ปีที่แล้ว

    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.

  • @gerrardhickson9471
    @gerrardhickson9471 ปีที่แล้ว +2

    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?

    • @kevinmcaleer28
      @kevinmcaleer28  ปีที่แล้ว +1

      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.

    • @gerrardhickson9471
      @gerrardhickson9471 ปีที่แล้ว

      @@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.

  • @marcdurbach7036
    @marcdurbach7036 ปีที่แล้ว

    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.

  • @hiddencat3785
    @hiddencat3785 2 ปีที่แล้ว +3

    Wow! Pico W is a great thging!

  • @johnmuller5056
    @johnmuller5056 ปีที่แล้ว +1

    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!

    • @kevinmcaleer28
      @kevinmcaleer28  ปีที่แล้ว

      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?

    • @kevinmcaleer28
      @kevinmcaleer28  ปีที่แล้ว

      Have a read of this article: www.kevsrobots.com/blog/simple-robot-arm.html#the-web-ui

  • @parihar-shashwat
    @parihar-shashwat 2 ปีที่แล้ว +1

    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 ?

  • @peterwadsworth5994
    @peterwadsworth5994 2 ปีที่แล้ว +1

    I notice your logfiles have the correct timestamp, when I run the demos with logging, the timestamp starts at Jan 1st midnight 2021?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      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

    • @peterwadsworth5994
      @peterwadsworth5994 2 ปีที่แล้ว +1

      @@kevinmcaleer28 , cheers Kevin, now syncs the time correctly

  • @mytechnotalent
    @mytechnotalent 2 ปีที่แล้ว +1

    Great job Kevin!

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      Thanks Kevin!

    • @mytechnotalent
      @mytechnotalent 2 ปีที่แล้ว +1

      @@kevinmcaleer28 welcome Kevin love your work!

  • @neilvermeulen5283
    @neilvermeulen5283 2 ปีที่แล้ว +1

    Thanx mate. You explained well.

  • @johnnijholt5480
    @johnnijholt5480 ปีที่แล้ว

    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?

  • @jcork3460
    @jcork3460 2 ปีที่แล้ว +1

    Kevin, Can you copy the PHEW directory onto another Pico rather than doing the uPip install?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว +1

      Absolutely - you can download it and copy it across using Thonny, or even install via the Thonny package manager

  • @compubyte2010
    @compubyte2010 2 ปีที่แล้ว +1

    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?)

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      I asked Pimoroni and they think Phew will work fine on CircuitPython

    • @compubyte2010
      @compubyte2010 2 ปีที่แล้ว +1

      @@kevinmcaleer28 SO would I type CircuitPython-phew within CircuitPython? or do I still type Micophython-phew within circuitpython?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      @@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.

  • @JoshF151Tech
    @JoshF151Tech ปีที่แล้ว

    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?

  • @JustinWolliesWollies
    @JustinWolliesWollies ปีที่แล้ว

    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 ?

  • @ronaldwernecke9981
    @ronaldwernecke9981 ปีที่แล้ว

    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?

    • @user-vh3lm3qo4t
      @user-vh3lm3qo4t ปีที่แล้ว

      mpy replaced upip as the package manager

  • @gandalfsVater
    @gandalfsVater 2 ปีที่แล้ว +2

    Hello, i tried to import upip but it just throw the error: ImportError: no module named 'upip'

    • @stevemorse5052
      @stevemorse5052 2 ปีที่แล้ว +1

      Hi Gandalf, I have the same problem and have been unable to find a solution. Were you able to solve it, if so how?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      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

    • @stevemorse5052
      @stevemorse5052 2 ปีที่แล้ว

      @@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?

    • @danahuff6823
      @danahuff6823 ปีที่แล้ว

      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.

  • @Bubby9767
    @Bubby9767 2 ปีที่แล้ว

    closing body tag ?

  • @devinalmanirwasita524
    @devinalmanirwasita524 2 ปีที่แล้ว +1

    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 :)

  • @benid696
    @benid696 2 ปีที่แล้ว +2

    Interesting stuff thank you 👍

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      Thanks @Beni D! I’m still a bit frustrated the last demo didn’t work properly

  • @jazzjohn2
    @jazzjohn2 2 ปีที่แล้ว +1

    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?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      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

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      How to build a captive portal with MicroPython - the easiest way EVER!
      th-cam.com/video/2Y42DSZpR0w/w-d-xo.html

  • @allancarey8038
    @allancarey8038 2 ปีที่แล้ว +1

    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

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      Sure - check out GitHub.com/Pimoroni/phew

    • @allancarey8038
      @allancarey8038 2 ปีที่แล้ว

      @@kevinmcaleer28 thanks Kevin!

  • @christopherlyons7613
    @christopherlyons7613 ปีที่แล้ว +1

    upip no longer supported, need to use the mip library.

  • @frankysnephew
    @frankysnephew ปีที่แล้ว

    0:58 Are you sure it's not 'ukip'?
    (Asking for my friend. His name is Nigel.)

  • @Goman1244
    @Goman1244 ปีที่แล้ว

    Love your video

  • @slavauchitel8014
    @slavauchitel8014 2 ปีที่แล้ว

    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.

  • @nickatchison9906
    @nickatchison9906 ปีที่แล้ว

    COOL stuff.

  • @martinnash007
    @martinnash007 2 ปีที่แล้ว +1

    Did you manage to fix the code?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว +1

      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

  • @pranavnivas4905
    @pranavnivas4905 2 ปีที่แล้ว

    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' "

    • @danahuff6823
      @danahuff6823 ปีที่แล้ว

      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.

    • @pranavnivas4905
      @pranavnivas4905 ปีที่แล้ว

      @@danahuff6823 Thank you so much that works perfectly. 😊😊😊

  • @repsej74
    @repsej74 2 ปีที่แล้ว

    Great video, Thanks !

  • @britishtechguru
    @britishtechguru 2 ปีที่แล้ว

    Where do I get Phew?

  • @ixxeon
    @ixxeon 2 ปีที่แล้ว

    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

    • @ixxeon
      @ixxeon 2 ปีที่แล้ว

      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.

    • @danahuff6823
      @danahuff6823 ปีที่แล้ว

      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.

  • @DamjanDimitrioski
    @DamjanDimitrioski ปีที่แล้ว +1

    have you benchmarked how many clients can be accepted as a connection on the server on a single Pico?

    • @kevinmcaleer28
      @kevinmcaleer28  ปีที่แล้ว

      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.

    • @DamjanDimitrioski
      @DamjanDimitrioski ปีที่แล้ว

      @@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.

  • @clivebarrell6448
    @clivebarrell6448 2 ปีที่แล้ว +1

    Q is it phew pronounced "few", which would be the usual English, or "pew" as in church pew, which sounds strange here?

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      Jon says is Phew as in ‘phew that’s a relief’ and not as in pew ‘pew pew’ Han shot first

  • @Davidmorehouse1991
    @Davidmorehouse1991 ปีที่แล้ว

    Cheers!

  • @tubeDude48
    @tubeDude48 2 ปีที่แล้ว

    You were all over the place!

    • @kevinmcaleer28
      @kevinmcaleer28  2 ปีที่แล้ว

      What do you mean?

    • @swedishpsychopath8795
      @swedishpsychopath8795 2 ปีที่แล้ว +1

      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.

  • @schlingelgen
    @schlingelgen 2 ปีที่แล้ว

    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.

  • @imrichmorvay2227
    @imrichmorvay2227 2 ปีที่แล้ว +1

    great video just i didnt learn nothing

  • @pierskennedy446
    @pierskennedy446 ปีที่แล้ว

    Apollo 13 had enough problems as it was - contacting 'Huston' would not have helped at all.

  • @robjr657
    @robjr657 2 ปีที่แล้ว +1

    I thought Al Gore invented the internet. 😜

    • @robjr657
      @robjr657 2 ปีที่แล้ว +1

      I really enjoyed this video... Thank you Kevin.

  • @etfexpectations-sectoroutl5323
    @etfexpectations-sectoroutl5323 7 หลายเดือนก่อน

    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."

    • @kevinmcaleer28
      @kevinmcaleer28  7 หลายเดือนก่อน +1

      Try this instead pypi.org/project/micropython-phew/

  • @vynylPooh
    @vynylPooh 2 ปีที่แล้ว +1

    flask(Phew) in micropython! It's awesome!