 All right. Good afternoon to everyone. Happy Friday to all. I am back here for the deep dive this week. Let's check in and make sure I got things running correctly. Okay, we show live there. We show live on this one. I clicked the YouTube button. I think we are... I think we are all good there. Let me shuffle around a couple of these chats. How's it going to Clever as well as Michael Pocusa over on the Discord? Let me also say hello and thank you to, let's see, Daniel Hogan over on the YouTube. I did not know this was a thing really. I'm not necessarily up on the YouTube streaming, I guess. But it looks like we got a super chat. $2, I guess that's like a donation of some variety that's going to go into the Adafruit account for that. So thanks for that, Daniel. I appreciate it. I hope that you enjoy the live stream here. So without further ado, let me say hello to everyone. My name is Tim. I go by FOMIGuy on GitHub and Discord. This is the deep dive program, which is now ordinarily a weekly live stream program where Scott, the lead developer of CircuitPython, is working on different various stuff related to CircuitPython. Scott is out this week. He mentioned during the meeting as well as maybe I think on this stream last week that he is moving to a new office. And so that's where he is at, presumably today. He was unable to stream today. So I'm filling in for now to the best of my knowledge. I believe he is going to be back next week, although I have not specifically talked with him about next week. So don't hold me or him to that. But to the best of my knowledge, I think he's back next week. Deep dive is a program where we're working on CircuitPython stuff. Typically, Scott is obviously deep dive, as the name would suggest, down really, really way deep in the core code. I am not quite to the level of depth, you might say, as him. So oftentimes we are working in the libraries. We're entering into the core at times, but definitely not tackling as crazy as stuff as he is typically working on. So today we have some library stuff lined up. Let me give a real brief introduction, though, for anybody that might be catching this on the video in the future, or even if you're watching live and you don't know what I'm talking about yet. CircuitPython is the project that this live stream is centered around. You can learn more about it at the website circuitpython.org. This is basically an implementation of Python that runs on tiny computers called microcontrollers. In this case, I have a Metro ESP32S2 microcontroller. The main brain, so to speak, on this is inside of this chip here. And in this case, CircuitPython is running on that chip, which means that it can actually interpret and execute Python code. So when you plug it into your computer, it shows up like a thumb drive. You can edit a Python code file on that drive, and then this computer inside this tiny chip will execute that Python code. It can interact with other peripherals. In this case, we have lots of IOPINs with this device. It's kind of made as a sort of prototyping platform, I guess, so it's got lots of IOs broken out. It also has a microSD card, and one of the big benefits of this particular main chip is that it is Wi-Fi capable, so it can connect to Wi-Fi networks and do other things. There are all sorts of different shapes and sizes of these microcontroller devices. So this is the one that I will be messing with today, but there are lots and lots of other different ones here. At present time, there are 425 devices that have support for CircuitPython. And you can find those over on circuitpython.org slash downloads, which is actually where we're going to start, because I'm going to want to download the latest version for this, I suspect, because this is fresh out of the package. I did take it out of the package, obviously, as you can see it right here, but I have not powered it up or done anything else with it. Let me also say, before we get going too much further, thank you to Adafruit. This is their website, Adafruit.com. Adafruit is a hardware and software manufacturer based out of New York in the United States. They are the company that is the primary financial backer for the CircuitPython project. So Scott, the lead developer of the project who normally streams at this time, is paid by Adafruit to be the lead developer of the project. I as well as several other folks are paid part-time, and there are a couple of other folks who are on the full-time team as well, all paid by Adafruit to work on the project. So obviously, huge thanks to them for making it possible. And if you want to help support the project, one of the ways you can do that is head over to Adafruit and purchase hardware from them. They design and sell the microcontrollers like the device that I'm using here. They also have all sorts of add-ons, so to speak. Little breakouts with sensors, speakers, sound makers, lights, LEDs, buzzers, buttons. Every kind of little electronic widget that you can imagine, they probably make a little breakout which will allow you to connect that thing to some microcontrollers. And then if you want to use CircuitPython, you can write some Python code to interact with whatever that widget is. So thanks to everybody who purchases hardware from them, that helps the CircuitPython project keep moving. Take a swig of coffee here. Today's docket, the docket for today for me is looking into this. I saw this go by the other day. We were working on some CircuitPython HTTP server stuff last weekend on my stream, which I'll talk a little bit more about later when it's about time to wrap up. For now, the important bit, though, is I was working on a project that uses HTTP server. I ran into a couple of things where I was like, what if it could work this way instead? Or kind of in addition to what it does. And Michael Pocuse, who's in the chat as well. How's it going, Michael? I don't remember if I said that or not. But thanks for stopping by, as well as obviously all the work that you have done over quite a while now on the HTTP server. So I was talking about that stuff, kind of trying to get my thoughts together. And it turns out Michael actually checked out the stream and so kind of got all of my thoughts sort of raw as they happen. And actually already even has put a request in four days ago with a lot of the stuff we were talking about. So we're going to try it out. First, I'm going to check out what all is in it because I don't remember everything. So it does say token instead of bearer. I think somebody mentioned that while I was streaming last time about how bearer is maybe for basic auth or something. And so now there's a different way to do that with token as well. So we'll test that one out. The redirects we did find. So we were doing like is it 307, 308 redirects which have the restriction. It turns out of you have to keep the same method, which means like get or post like the HTTP method, which means you can't with the 307 or 308, that means you can't accept a post request and then return a redirect to a get request with 301 and 302 you can. That's added now. I've been diving more into the core lately implementing tile grid Excel on the Broadcom port. Oh, that's that's super cool. Yeah, that's that's pretty awesome. It sounds like you've done a lot of great display work on the Broadcom port doing a lot of stuff on the pies over there. If I encounter any issues with the current PR state, I can make fixes live as it goes. Nice, there you go. So we have live. We have some live PR review action. That's that's really cool. As somebody asked about doing that once was it David Glauda, I think mentioned it before just kind of offhandedly during a stream that it'd be cool to do some live PR review with the person who did the PR. So yeah, that's awesome. Let's see. We have our two different redirects. We have headers get parameter get directive to new methods for headers get directive get parameter add and set. There's I'm not sure on what that one does, but we'll play with it to try to get a better idea. I'm very much a play with it kind of person. A lot of times when it comes to understanding stuff. So request that cookies, we did talk about that one. So that looks like it's now a dictionary ish type thing for getting the cookies out, which is cool. So we're reading the header and then parsing it out from there. This is like convenience. Accessor looks like added the docs for cookies request dot form data dot files uses new files and files class representing. Oh, interesting file uploads. We'll test out the I'll test out the SD card. So this one I don't know if I ever mentioned saying all the cool stuff about this device, but one of the other really cool things is it has a micro SD card slot. Also one of the really cool things, which we'll see when it plug it in, is it actually has kind of a lot of storage, at least in micro controller standards. So we could theoretically maybe take a file upload and store it on the SD card, which will be nice because it's actually a little bit tricky if we want to store it on the internal storage because it's read only. Unless we change it to be writable and then we have to swap it back and forth and play this little dance. If we can get the SD card work in, we'll try that. I think I heard though Scott mentioned something about the SD card. There may be issues with it. I don't know what context it's within or what, but if we run into trouble, we could either try a different device with an SD card or store the files on the internal by using boot pie added a tuple for route methods. Oh, okay. I think you used to have to do list. I tried maybe a tuple and it didn't work fixed. So I read this one this morning. Actually, this one was if you have no, if you submit a form with no data, apparently it caused a crash value error, which I had never noticed before, but this person did right here. Red air 6000. That's fixed in there as well. Redirect has preserved method. Okay, that's a good way to do that. I was struggling to come up with the right way to expose the API for that, but add another Boolean is nice. So you have redirect. I think it's permanent maybe is the other one. There's another Boolean flag, which was previously letting you select between 307 and 308. Now we have preserve, which would, if that's true, that one would be the 307, 308, 301, and two are the non-preserves, cool. Status. Oh, okay. So setting, yeah, that's cool as well. Setting the status. So we did, so when I ran this before, the 301 status, what do you call it, enum, like helper variable didn't exist yet. I was returning it quote unquote manually, and we had to make a tuple or something with the status in a string. This allows you, it looks like, to put an int, new status parameter for setting the manual status codes. Sounds like maybe that'll be a little bit easier. New docs for redirect, debug messages changed a little bit, elapsed time. Oh, that's cool on the end there, nice. How long it took. Yeah, that's actually really interesting. That's faster than I would have expected. Some of these microcontrollers are pretty speedy though, honestly. Updated the docs for the form data, typing for the query params, form data headers, server, server forever, now accepts a pull interval, which adds a delay between calling pull interesting, okay. If you could set like, you know, five seconds or something, it would wait that five seconds between, whereas before it would have just gone as fast as it can, I assume. That doesn't mean your clients get have to wait though, right? So if you set five seconds, then that means a client could be waiting, you know, up to five seconds or a little bit less, I guess. No content type in the post. And then refactoring on the field storage. Okay. I'm going to pull this locally as well. So I have this, which will have our device in it. I'm going to open HTTP server. SD card can be RW independent of circuit pi. Yeah. Oh, unless perhaps, oh yeah, yeah, like on the Raspberry Pi, yes. But do you know whether it's possible to write to the SD? Oh yeah, yeah, yeah, yeah. I think that is correct as far as I know. I do think though there is, is there a 76? Oh no, that's only in my preview. Yeah, okay. For a second, I just caught OBS out of the corner of my eye and I was like, is there a random number on top of my face? No post on Sundays. If you, if the SD card works. For some reason, I thought I recalled Scott mentioning during like in the weeds or something, maybe during the meeting, something about potential problems with this device and the SD card. If you're talking about the little switch on the full size, it's optional. Read only as a suggestion. Oh yeah, yeah. Well, I haven't, I mean, I have the adapters, I guess, but I haven't used an actual full size SD card in so long. I do remember they had the little switch. Okay, so first thing we will need to do for sure. Well, and I say first thing, which I've already done a bunch of things, but one of the, the next thing we need to do, let's put it at that, is get CircuitPython loaded. Right now I have my device plugged in, but there's not a CircuitPy drive or anything showing up. They don't really have any action going on or anything. I don't know. Maybe the NeoPixel would be kind of drowned out. No, it doesn't look like we have any kind of action. So I think we're probably on some kind of Arduino, maybe a pin checker program or some kind of demo or maybe even just printing into the terminal. What we want is CircuitPython. I'm just going to grab, I think, absolute newest. We could get 824, you know, I don't know. I'm a, I'm usually a go for the brand newest one. So I would assume a UF2. I don't know for a fact if we have UF2 probably, but let's see. And then do we have a boot on this one? There is boot. Where's reset? Reset is, there's a switch. Oh, this has turned off. That's probably why I didn't get anything, although I didn't get anything more. Also, it's actually probably turned off right here as well. Okay, okay, okay, yeah, yeah. It is doing something now. It's powered on. Did I actually get a drive though? The lights, it is a little washed out. I guess I could turn the light off, but too much to see. Storage, remount, read only parameter. Yeah, yeah. During my testing pull interval, fixed the random restarts of the MCU. Oh, interesting. I don't use serve. I don't use the serve, the long one very much serve forever. Yeah, yeah, software read only is what we're talking about. I think for this one. Okay, that is running. I don't think we still didn't get a circuit pie drive. So I do think it's probably on Arduino of some sort. How's it going? Wayne Taylor over in the YouTube. Thanks for stopping in. Check out the stream. Hope you're having a good evening or day, whatever time of day it is. It's getting to be about evening time for me. We downloaded that. We do have a boot. Where is the reset? That's where I actually left off. Where's the actual reset? You know, I kind of want the light on even though it washes out the LED. I think we're going to put that back. Where is reset? So maybe there is no reset. Maybe there's only the switch. Oh, no, there is a reset up here. Okay. So is this a double tap reset? Or is this a hold boot? There we go. Okay. Double tap reset. Let's see. As in calling a REST API from the ESP 32 to send data. I assume that you're asking about the title of the video, essentially. If my understanding is correct, other way around, basically, we're running the server on the ESP 32 and it's an S3 in this case, not just the plain ESP 32, but the S3 one. We're running the server on that microcontroller and then we'll be sending the request to it from other stuff. It could be that we sent requests from a different ESP 32. In my case, I will not be probably doing that. I'll be sending the request from my PC, but obviously the request they could originate from anywhere, including a different microcontroller. If that does not answer the question that you intended to ask, let me know and I'll try to answer better or differently. Okay, we should be back. Yeah, now we have CircuitPy with kind of default stuff in it. We got a CodePy, probably just print hello world, and then we got a settings.toml, which is nice touch. I don't think it used to do that and it's fairly newer. I will need to set some stuff in my settings.toml, which I'll need to do obviously off the screen. Oh, this is HTTP server. Where's this? Refresh, there it is. Pick a pie. Okay, so here's what I'm going to do is we're going to bounce this over to here for now. I'm going to double check that I am showing you this one. Here I am, and then we're going to steal our settings file from a different device, except for that, it uses a different kind of plug. Yeah, one second. Plug in the feather tft for just a moment. And here. Okay, sorry, yeah, there's not going to be much to look at right this moment, because I need to copy this over and I can't show you, obviously. But just imagine it's me copy pasting my settings.toml file. And your imagination will be pretty much 100% right. Yeah, okay, close that. Open this. Bring that back. Had the idea earlier, since the USD on the RPY is so large, you could afford to split it in half one partition. Yeah, partitions. Well, I mean, on the Raspberry Pi, it's probably a different equation than on the microcontrollers. I would love partitions on the microcontrollers. I would love to have a little, like if I could dedicate maybe like a quarter or a half of the space of the built-in storage to be read, right? I think that'd be super cool. But I think it can't work. I think it's not possible because the way the storage is not stored by block and not by files or something. I don't know. I think I heard Scott explaining it one day, and it's definitely over my head, but it made it seem like it wasn't possible, essentially. But the built-in SD card is nice because, like, SD cards are free effectively, right? You can buy an SD card for, like, $3 or $4. That's 16 gigabytes or 30 gigabytes, and it's, like, more storage than the microcontroller will ever even dream of using. It didn't mean to hijack the stream. No worries at all. One of the things about this stream, both for when I am here and when Scott is here, I don't know if you are, I assume, maybe a newer viewer who hasn't caught it before, but Scott is the one typically streaming at this time. These days, one of the things about that stream, both his and mine, is we're both totally cool with Tangents, right? If you have questions, we're both pretty happy to dive into the answers a bit. So, yeah, no worries at all on that. Issue is the host PC can't share the fat with another host, but with partitions you can have two fats and only give one to the PC. Nice, okay. So we're gonna, I'm gonna get the latest version of the code, which is, well, not latest, but we're gonna get the one from the PR. GHPR list, GHPR checkout, 67. I'm gonna copy the library, just the Python version of the library. We're gonna drop that in lib. Do we need anything else? Does it need requests or anything? I guess, probably not. We'll see though, let's see. Let's get TO connected as well so we can see, oh yeah, I chose pirate. That's nice, okay. Let's get examples. Let's start with just absolute most basic, oh, I don't need manual, we could do auto. I think auto versus manual is like the Wi-Fi and we should be automatically connected to Wi-Fi, I think, because of my setting stumble. So this one is saying slash static and it has a slash to return a string, so we don't need slash static. Oh, this did not, it actually, it failed. I guess we do need to do manual. One second, let me look at my setting stumble again. I think there's a switch in there as well, maybe could I have turned it off? Or do I need to like full on boot up again? CircuitPy, Wi-Fi, SSID, SSID password. No, just password. I'm gonna give it the old reboot-irony here. I'm gonna use this cute little switch that's on it. See if that makes any difference. Oh, interesting, we got some boot loader stuff there. Nice, okay, yeah, we just need to restart. Now we're good, it looks like. I wish this had copy link. Oh, it does, nice. Thanks PyCharm. Reset, nice, okay, thank you. Auto is faster when reloading. Auto, this keyboard's coming with 816, would be a nice partition, yeah. Yeah, yeah, yeah, especially, especially eight megabytes, which is, I think, is that what this has, eight megabytes? That's what I was thinking in my head. Is like, oh, it's even bigger, so that's the 16 megabytes, I guess. That, like, that's basically, that's so much space for a microcontroller. So nice, okay. Nice, okay, there's our response from the server, and then we got all of our stuff, so that's part of the new bits right there. We, interestingly enough, it actually, it took it longer to return the 404 on the favicon than the text, but my guess is that 404 was probably technically a bit larger, because this text is very small. Let's make a static. Let's put in there an index, and let's put on that index the most creative thing we can think of, which is an H1 that says hello world. And then I think that does not change this, but we would be able to do this now. Get our page, cool, okay. All of that stuff is working. I will test first. Do we want to go in order? I'll start in order. I may jump around a bit afterwards, we'll see. But I'll try the token first. Authentication class works the same way as bearer, but it uses the token redirect. So what I'm going to do is get the example for authentication one, which is here. Ah, okay, this has token in it now, nice. That makes it easy. Okay, cool. So then check if authenticated require or 401 require or handle. So basically, this one uses this logic here to check if the user is authenticated and then returns them a response based on what it found. This one uses that function, but if it's not authenticated, it maybe modifies something inside here, which then gets passed to this. Oh, if it is authenticated, excuse me, if it is authenticated, then it returns effectively true. If it's not authenticated by default, what it would do is the 401 it's saying there, which is the status code 401. And then or handle manually, so now we have try catch do the thing, if it's true, return the good version, except if we weren't authenticated, then this one is manually doing whatever it's doing, in this case, returning a response also 401, but it could do anything it wanted, obviously. Okay, save this. Do I have, so auto reload should be on no module unauthorized. Let's see. Maybe did that one get missed inside of a knit? Did knit have a big list of stuff? It does. Oh, actually unauthorized is right there though. Does it need status on it? It might need status on it. Wasn't there some discussion of defaulting to index when the path, I think it does if you don't handle it. I already overwrote my old version, but if I go back, I think the reason why that didn't go to index is because we overwrote slash here and we returned this thing here. If we did not have that, or if this was something else, then I think by default it does look for index, but Michael also already answered and definitely knows better than I do. Yeah. Can do via Web workflow. Oh, is there a directory listing in the HTTP server? No, yeah. She got answered already as well. Mainly for keeping the code base smaller. Yeah. It is amongst the larger libraries. That is definitely true. Yeah. I would see the directory listing potentially as a problem that goes along with templating, which is another problem that I'd like to see an answer to. I think the answer is probably a separate library because the file listing I think the easiest slash best way to do it would be with a template that can then for loop the files effectively. I've been researching a little bit. I have not actually tried this thing yet, but I have found there's this, which is something I want to try. It's kind of a potentially a better version of the real quick hack job I did on the project I was doing last week. But if we had templating and I think separate library is probably the way to go at this point just because the HTTP server is starting to get a bit big but if we had templating then it'd be super easy to have a template that is a file listing and then maybe you could turn it on optionally if you wanted. You had authorized spelled incorrectly. I don't know which page I was on. Yeah, sorry. I don't know which page I was on. Oh, in this thing maybe. Cannot undo. Oh, there we go. Oh, yeah, yeah, yeah, yeah. AU. There you go. Yeah, thank you. Who is Aaron? Thank you. Appreciate that. Yeah, coding on a live stream is so nice. You can have people check. That's like a thing I totally would just have not got at all and just been convinced that the dot status was the fix for that for the rest of my life. I would have been probably. So, yeah, thank you for that. I have to run right now, but I'll catch the rest of the stream later. Need to use HTTP server for an upcoming project. Awesome. Yeah, take it easy, Ryan. Hope you have a good night. Thanks for checking it out. Mainly even now, I can't imagine someone wanting templating but now HTTP server even Django uses Ginger or something for the templating. Django, I think, has their own at this point, but it's kind of based on that if I understand correctly. Okay, I don't know if I ever did save. I think I saved this, but then we restarted it. Okay, there you go. The fix on that might there was just typo on the A after the N or before the N or whatever. Michael, you want to swap that one on us? So then we can do check and we have we have a couple of ones. Do I still have my tests for this thing? No, we're going to make some more. Have a folder. Okay, well, that's okay. I clicked on the wrong one. Here we go. We have a folder for it. I don't know if it is truthfully exactly what I want to use, but I'll just make a new one in here. Once I make this, then we'll copy it. Well, let me just do it this way. Okay, let's do basic first. Double check basic, make sure it still works. So I have saved this now. That is running. So we go back to here. Oh, but it's not here. We want this one do static. Okay, yeah, this one does not have static, which is why we did not get index, I think. Hail nerds. Yep, how's it going, kid Fitty? Thanks for tuning in. We will go to slash check not we are not authenticated. I am a little surprised it didn't give me the pop up thing. Shouldn't it give me the pop up thing? I wonder if I have like is that different from before? I'm going to try the old version real fast. I thought it would give you that pop up like the old school JavaScript alert. Where did I get where did my browser go? I do with the tab. No idea what I did with the tab. That's cool. Maybe the 401 maybe we need the 401 actually let's try require or 401 require or 401 that's okay so so because it didn't return so that thing pops up like the client browser is responsible for that probably this is my understanding after now seeing it the client browser is responsible for that and it's only going to do it when it sees the 401 because this one did not return the 401 it did not pop up this thing which makes sense everything could be used by end user is importable directly okay that's good to know that you can import everything does that no changes okay okay so our basic auth what is our stuff it's just user and password password ask me if I want to save I'm going to say no or click out of it I guess so now it does it should save the cookie though so I think now if we go back to check it does yes still authenticated so that's cool yeah and then for the other two here we will need to oh there's one other spot to change this down here as well that was typoed in both spots unauthorized let me save that so for these two I'm going to make scripts for them they can be either get no no no actually they have to be get because they don't specify method so I'm going to do bearer first because that's the older one import requests re response equals request get URL is the server slash check yeah print response dot text so that should be not authenticated test doesn't like the fact that there's test in the name and I doesn't like what I mean is it tries to run it differently than just running it as a python file if I make it not test will it run okay so we get not authenticated and then we can add the cookie with cookies so we want authentication and then this one we're doing is bearer so bearer space and then our key let's use a fake key right now though this should give us a well this should just give us not authenticated oh I messed this up okay not authenticated let me duplicate this and do what's the 401 checker 401 require 401 let me do that so this one should return the 401 doesn't really show us much let me do response response 401 let's do print fstring status response status code content oh sorry I accidentally bonked the microphone I don't know if that was loud in my bed one could see even subclass token to have a different prefix interesting it's kind of cool one so that should give us the content status 401 and then empty content and if we go back to that one we'll get 200 with our not authenticated but if we have the real password it's not a password but a token let's we can test this let me put the so the oh I'm doing bearer actually let me put token so we'll test to make sure because token shouldn't work for bearer if I understand so we put this and then we expect not authenticated still I gotta re-remember the alt tab between these I don't know I don't know what it is maybe control tab that is control tab looks like and you can keep going through the list interesting I gotta try to remember control tab control tab that'd be super useful if I could commit it to memory and use it I don't know that I actually can though oh I didn't change the password on this one let me do that first I'm not expecting anything different but just in case what's the one to run it also that's just control f5 I thought I made one like alt r is that gone I guess I don't know ff10 alt r and 401 control tab copy control tab gonna replace both at the same time alt r say alt r still got a 401 I've been messing up bearer the whole time or did I mess up authentication let's try this one authenticated got this idea for off-grid networking powered by solar and wind it's internet repeaters on local network outside so when you're cutting wood in the forest you can listen to mp3's from you or Shack perhaps develop new internet with wi-fi microjoules nice yeah I know there's a there are a few projects out there working with mesh mesh networks and stuff like that um is it supposed to be authorization not authentication I might have messed that part up says authenticated let me look at what I done before like in uh new pixel test ones this one is authorization none of the none of those would have ever worked okay copy paste since uh best was spelling either okay so yeah all those tests where I had the wrong password we also had the wrong name of the cookie so it would have never worked anyway so yeah not authenticated actually though I'm too long am I sure that cookies works like this no I'm not let's check that requests authorization requests cookies mesh network stuff's basically not working without the internet I don't really want to do this session I guess we could if we needed to but cookies equals cookies I did cookies equals dictionary authorization if it only sends as a header I'm not sure what you mean which I mean it should be a header I guess right because it's where the cookies go but I'm not sure I understand what you mean use cookies do I have to use header instead of cookie manually set cookie in headers um boy it'd be convenient if I could see the request can you see the full request you make a function that does that but that's the response but it does say response.request okay so URL was that body was empty make sense it was a get request headers was this oh it put a uh is it supposed to be an equals authorization bearer I don't know if this one changed intentionally or not but I think it used to not wait well but but this is the way I'm sending it not the way the server is reacting to it so yeah obviously the server is not reacting right because I'm not sending it right why is that like that oh wait that is well because cookies could have multiples in there I guess it's not supposed to be a cookie is it that's what you're trying to say in the header I think yeah I think I'm catching up at this point it's not supposed to be a cookie it's supposed to be an actual header called authorization yeah headers not yeah okay yep yep yep yep sorry I am got too excited about the cookies uh I got too excited about the cookies property got ahead of myself it's not really supposed to be a cookie yeah and then I didn't understand when you told me before we made it in oh why is that made it in the unexpected argument headers there we go okay in a long day I guess that is working when we have the proper password let's do go back and test the wrong password again since we were not actually doing valid tests back then not authenticated because I gave it the wrong password also been putting this one inside token instead of bearer which is what it should have been in oh no I didn't test token bearer okay I I made the back I made the names wrong really is what happened it should be one of them should be bearer and one of them should be token wait why was that empty oh yeah one of them is empty what's the last one require or handle let's add that one as well why we're here might as well do the third test too so this one is with we could turn these off I think for now this one is with the wrong password handled manually and then this if I understand right it's the exact same thing just with this saying token instead of bearer so that one and then also in this case it has different token as well although you could theoretically use the same I guess I mean you probably would only use one or the other in most cases I guess wait what was that it's like extra clipboard stuff that's interesting authenticated last one okay all good redirects I think are next which was their redirect example redirects skip that one you just get the code I guess the file so we have Google a fruit circuit python slash blinker redirects to circuit python slash blinker permanent true status moved permanently preserve method true get permanent and preserve method and then you can also just do status as well directly log in redirect let's log in reserve method interesting I might make an example that has a an actual fake login actual fake user account to log into to show accepting the posts with data validating it and then returning basically like an example of how to do authentication separate from the library all the authentication that we've seen so far is all handled by the library but the user could make their own scheme with their own what I'll call a database although I don't know that we have support for any straight up sequel databases or anything but they could have their own database some other format validate their users themselves another example I want to make for people is one that shows storing stuff submitted in a form in the NVM so they submit something in the through a form and it's stored in NVM and then maybe it shows on a different page or something because I see folks ask for stuff like that like making a configuration server page where you have configuration values that you can enter in on a quick little mobile page or whatever have them saved in the microcontroller so we're basically going to just slug is none or not roots so this one will not get handled by here because it will already have matched this I think but then for the others slash google and slash circuit python would redirect to the value given inside the dictionary so we sent our get request to blinker slash blinker we got a redirect with permanent true to slash blinker and then permanent I believe is 301 instead of 302 that's moved permanently right there again we still got 301 but I don't did I save well I did save maybe that's not true was permanent 301 versus 302 302 it's like found though not permanent I guess but it's moved permanently temporarily I don't know why this is called moved permanently and then found like should be moved permanently and moved temporarily should that if permanent is false shouldn't should that make it be 302 alright 301 I think that should be 302 maybe if I'm understanding these correctly at least is that one says permanently and has permanent in the name this one doesn't have non permanent in the name or temporary in the name like it should in my opinion but it does still specify temporary that's one thing I think I would probably changes make that if you do false then you get 302 true you get 301 back to true it doesn't really matter what we leave it on show raw has gone be out slash Adafruit is 301 we expect slash login needs to be a post let me do that one last slash slug so we can do Google or circuit Python and those will be whatever is default switches I think 301 probably but we'll see so slash Google and slash circuit Python 302 302 is the default going better just came home with ice cream nice it's down for some ice cream myself as well that was a 302 which is the same thing slash circuit Python and then slash Adafruit we could use but it is going to hit this not this and then slug we could do an unknown one like slug we get unknown redirect because it's not in the dictionary so the login not test login post redirect slash login we don't need any headers we're going to send the post I will turn all this back on I guess well we don't need the headers actually we don't need any of this this is all URL stuff status code we're interested in and actually we're kind of interested in headers as well let me do like let me do some stuff here let's say print get some response data here so right now it's going to send a get request it should get a 405 or something 404 okay well it got a 404 because it hit the slug one so it hit this one because it note like we sent a get request so we did not match this we send it to this URL but because it was get request it didn't match but get login I mean is a valid slug that could go here so that's the one it hit which is the response we got back if we send it post that's when we should be getting back our redirect except I got a 405 not allowed why did we get that flash login post doesn't this need to be in a either a tuple or a list or can it be by itself methods string set that's weird we got different way okay I think maybe I understand what happened here actually so I think that requests probably followed the redirect automatically I think the server gave us the redirect request then followed it and because because it is a 307 preserve method is on it means that it's then gonna send a post request to here which will not that will be a 405 because it's not a probably not set up to handle it I do want to see the URL will it show us will it show us the redirect one or will it show us only the original one the redirect one so that's where we so then we sent our 405 to there and we got our not allowed back I would love to I think not send traffic to I go back and forth I guess I'm not sure I feel super strongly about it but I think I'm inclined to say we probably ought not to send the invalid traffic to the real server doesn't matter that much at the end of the day because it's just gonna keep returning this 405 to us but it might be nice if we had some other place that would like maybe we could redirect maybe we could have another one of these maybe it could redirect to slash I don't know maybe we make a slash post on here or something like maybe it has another route because you can can you redirect to yourself from a post to slash post push the updated version of the example has a go mark embler please check again the blink of one it should be 302 I assume probably you mean check again after I update sure if I just check out again does that yeah copy that go to live that was okay I swear caught up there okay let's go here with that press the and then the link of one with permanent false should be now so let's do permanent true that's how it was initially was permanent true so let's do it that way again first lead this stuff this 304 not modified okay that's like just use the cached one okay so go whoops whoops whoops whoops whoops back that again so now if we go false here has gone Nikola welcome to my different industries live save this like a I still got through one but I wonder about cash I wonder about caching stuff right like that says transferred cached really what I need is like a control refresh but can't do that because it's a redirect guess we kill this and get a new one of these maybe I got a 302 so I think it gave me a 301 back in here because it's already cached I could clear the cash somehow like probably clearing history other guy did resend and we got a 302 now will change the login example handler curl vvv they were trying to do this and that's we're back and forth with stuff to hopefully get somewhere with something it's not a altogether an accurate representation of what's going on I guess it's a touch vague how's it going David Glada do you remember I see you're typing there do you remember if you were the one that asked at one point about a live PR review that's what we got going because we got Michael here in the chat and we're checking over into their PR and HTTP server so if you did not catch this one from the beginning if my memory is right and it was you that asked about that this might be one to go back and check in on if you get the chance let me grab the updated example because that part I did not copy over just login to fake login nice that so login that's going to go to our slug or unknown redirect but if we send our post request we got our temporary rm slash login and then that one sent us over to fake login which then gave us back a 200 typing about Teddy Rubin reviewing PR with the author in the chat nice today is the day although I think maybe we've done some HTTP server stuff before with Michael in the chat so then one test can you do fake login login preserve method true so the only other one if you did permanent false would that be a 308 or am I a step too far with that seven still okay that might be one but there be any caching here I'm not sure if requests has caching like the browser I don't think so but I'm not sure that might be another one though where a 30 oh wait a minute I did permanent false which is temporary yeah yeah yeah permanent true that's what I actually was intending to do and that one is permanent nice cool and then yeah we already checked the other one 301 302 nice okay so yeah those are pretty sure those are doing exactly what I expect now so it's truly through a seven temporary yep nope well this is nope okay what else is in the request dot cookies and I think there's an example for cookies so let me use the example so we checked token off is good re redirection is all good headers got new new methods get directive and get parameter not sure what those are is there a new example for headers authentication server and then cookies what do these ones do header headers got new method get directive and get parameters nope was for no cash okay for request nice thank you I appreciate the heads up get list get directive returns the main value directive for the given header name or default if not found get parameter you you ever create a headers object this one does use headers actually okay so we'll do this one as our test because it is using in this case it's using set cookie headers and adding two of the same one which is nice to test that as well okay see this one copy this these ones to here let's see directive is like main main value the main directive is like main value like text plane of the header and parameters are like char set the value directive is like the value side of the key value pair sounds like probably but in like HTTP lingo sounds like maybe vocab okay so that's like this so this one has what slash yeah just slash okay and then that will give us a page which I think we'll have something we can change on it this one is kind of stream don't know much about catch up back here I have you stream in the background find the topic super interesting my feeling is that with storage memory performance network on the S3 it becomes very interesting for people more on the software side and less on the electronic side of making yeah I totally agree like the the amount of space and RAM is getting to be where it's just like you don't have to think about it anymore it's definitely having the web server is great match for people who want to do web development don't know much about programming web server I was left in CGI I got you stream is very interesting I'll have to re-listen yeah I did not I messed with CGI just a tiny little bit CGI Python scripts um not very much though and then the next kind of server thing that I set up was more sophisticated it was Django after that CGI scripts that was a few years afterwards though use those little CGI scripts for a while a lot of stuff done with those disappeared from the screen oh I probably moved it or resized it or something thanks for the heads up oh wow it's like totally gone huh we do with it I wonder if there's like a key command that like minimizes oh says not connected thanks for the heads up I have no idea how that happened I probably clicked something I guess okay I think we just had to start with a P in my time yeah pro PHP Python and Pascal so they related to web sockets yep relatively recently web sockets was added here which is super cool also the other one which I didn't know about the long what was the other one the long standing I don't remember the name of it now but there is server server sent maybe server sent request or server sent response or something that was pretty cool as well it's a different technology for sort of long running communication back and forth server sent events that's what it is events yeah I'll just use this I guess we're in the old private here so let's get 154 dark theme light theme after changing the theme notice the tab stays open after changing the theme close the tab and open again notice the theme says the same so I am presumably on light currently I'll click to go to dark so now we're on dark and it did put us on question mark theme dark but we could take that off just prove that it's actually stored inside there see now we're just on slash and we're still dark but then if we go theme light it's going to put that back but it's also going to save into there where we can do this and then if we look at the actual request what we shall see is in the response header we have set cookie theme dark and we would have the same we do this in this case it's in the request because we're sending it back to the server theme dark that gets saved in there cool why is it does it replace value one and value two somewhere we changed to dark and light oh these are just extras do we have slash do we have those cookie one cookie two I didn't see those but I probably didn't pick close enough attention another place we can find cookies is over here in storage I only have theme oh but headers doesn't do anything is headers supposed to get sent back or is it just this one only an example or would cookies overwrite it interesting question I don't know if cookies would overwrite it it might be fresh nice we're still on the dark theme storage it does change we do this there we go so now we have theme is dark and we have cookie one cookie two value one value two over in network as well set cookie set cookie and then in our case theme was still one that we sent back because we already had it forgot to pass them to response we'll fix nice thank you connection sleep let me see where service in connection that sleep where you don't send bytes firewalls not devices hate that what else do we have here so headers get directive and get parameter I did not necessarily test exactly but we can try maybe print headers get directive so yeah it'll be interesting to see what does this do because it has two so I guess it either prints only the first one or prints both I close the other one oh it's in no it's in that private browser that's where the other one is that's right that's only the first one what does the docs say about it might even say already in the docs the main value for the given header default if not found it might be worth I mean it's super minor honestly but it might be worth specifying here the first there's multiple corrective and then what was the other one was get header get parameter get parameter which we don't get parameter is that the same thing I don't know if that's the same thing or not function takes through position arguments did not do that one correctly okay 70C 77 get parameter may look at get parameter get parameter name parameter returns the value of a given parameter the given header or the default if not found okay I see okay ours does not have that yet but we could we could make one we could say headers dot add special header and then that could be like two things with the semicolon between them so that could be like a world semicolon deep dive so then would be special header and then oh but we need we need equals char set equals so we could say special header other val equals do you do that to me every time that's so annoying deep dive nice cool so that pulled out that other val from there and then yeah the other one the get directive that one doesn't take this and it would get us hello world which is the main value or directive it sounds like it's the actual real name for that nice cool cookies which we tested already in the cookies one and that was looking good oh we should be able to see this also in here like special header yeah there we go see that here as well whoops ordered text so let me catch up forgot to pass response client does not send cookie header right now client sends cookie instead of set cookie right yeah client cookie without set ordered teddy rucks been cost of fortune to bring the delivery from us to EU probably the import fee as well and our children of that age nor small children yet so hope we'll be here before Halloween anybody working on frightening teddy rucks been that's a good idea that'd be pretty cool and get some like scary vampire words or something in there just checking in are you working on that is that one I think so yeah 67 is that right yeah yeah yeah yep that's the one we're working on add docs for cookie usage so we can check the docs by going to the repo and going into docs and I have an alias called CP docs which does the build but it's like I don't know Sphinx build something something something it's got a bunch of stuff arguments build we go to index really want to run it there probably just messed up the chat again didn't I no well maybe temporarily but it's back to working these does it right now so cookie that would be under where cookies but that's the example okay nice about the API reference server files that's the other new thing one of the other new things we would want request cookies sent with the request nice yeah so the header would be the raw value and you would just get the you'll equals separated but then cookies gives you this nice clean dictionary where you can just grab whichever one you want nice and easy no parsing no equal signs no semicolons none of it just get your string values right away form data files that uses the new files and file classes for representing uploaded files uploaded using multi-part form fixes for example as the route methods test that one real fast it's easy enough we could just change hmm I think is there a methods take methods I'll put that in here and then this has slash API which accepts four different kinds this thing does think it's wrong what is that expected type string or set but we got a list let's see if it works save it so slash API API you know what's interesting is I think we'll still have our cookies right if I go to storage yeah we still have the cookies since we're still on the same host it's kind of interesting so that returned us a JSON object if it was get objects which is just this thing nice okay yeah is this yellow for expected dictionary but got list oh is that supposed to be a list instead of a dictionary oh maybe you can return more than one I do think technically it's invalid JSON if it doesn't start with a object I also don't know if I'm like actually right about that it does still return fine what's the raw I have like a special thing that shows me this there we go I've yeah some parsers that I have run across they have told me this was invalid to start with a list on the outermost thing they said you have to have an object on the outermost thing so curly brackets I don't know if that's actually accurate or not but I also can't remember what parser it was that told me that maybe it might even be inside pycharm when you have a .json file I think that might be a let me try it real fast that's easy to test I don't think there's any need to change it either though right because like some parsers handle it just fine like my browser one here handled it just fine even if it's not actually valid but no it's not this because that is fine with it I don't know what it was must have been somewhere else it might not even be invalid honestly could just be whatever I was using was kind of janky would not would not put a past past him to be have you been using something janky so the list is working we could try real quick a post or a put maybe let's copy the login one not test post api quest post slash api slash post url headers status yep let's do all that send it untied I don't know if I crashed it on the post or if I crashed it when I ran this I got a response here okay so yeah we crashed it when we posted none type is not subscriptable line 36 oh I broke it by adding the second thing I have an ID I object in enumerate objects this have uploaded objects I did not upload an object that's probably why that's probably why it failed so we could do JSON equals but also the server is crashed is it maybe it's not actually maybe it was actually still running I did not give it an ID still though so even if I give it an object we should probably also have an ID I think the server was not actually crashed it just printed all that stuff okay there we go now we got success the response is this object added did it actually add the object so if we do a get request do we have three now oh look at that nice yeah cool so that gives you like a little sort of makeshift database in memory only which is cool I like the that's part of the example been out of coffee for like three minutes but I keep trying I've seen JSON parsers that accept oh weird wow just a value by itself like just a number or a string interesting even abuse JSON parsers with a percent function you know probably the craziest JSON parser I ran across was one that allowed single quotes JSON actually stipulates double quotes but I ran across a parser one time where it allowed single quotes and then what's even weirder is if you're in like just plain old JavaScript you can get by with no quotes for the keys which is super weird apparently the driver doesn't know how to use the intercom so I probably won't get my out of package until Wednesday oh like he probably had a I got you had a delivery but the driver just bailed on you give you the note or something instead of checking if you're actually there sounds like yeah we have times we get that from the UPS as well although they've been pretty good lately I'll say for me at least but okay we got our posts let's do a put it look like it was the same thing right I don't know if it changes anything that untyped did it change anything we got still none type not subscriptable it's not missing memory on my ESP 32 for all features I'm using server as processor while ESP role of terminal only oh nice okay so you got your project split up into two two microcontrollers kind of share the load so to speak json pars 42 okay so here's python repel is saying 42 is fine oh no no no this is not python this is javascript right json parses javascript expected token yeah so it does so javascript itself allows the number by itself the string by itself but does not like these single quotes yeah I can't remember part of a I think part of a game framework libgdx maybe and then like something associated to libgdx can use json files and then those files were allowed to use these like funky extra formats that are not necessarily real formats but like you know I don't know it's not that far of a stretch right json with single quotes is not like not that far out there it's just technically not valid but this thing had support for it which is kind of cool kind of weird at least so what did we we got none type it is still 36 object id none type object isn't scriptable so I did still upload I did upload an object though maybe that doesn't work maybe dot json maybe dot json doesn't send the maybe dot post I mean dot put I mean maybe put doesn't send the json and post does I didn't get hardly anything remote disconnected we didn't get we didn't get a response I mean I think that means we're just not getting an object right I'm betting that's different I'm betting that's a thing with requests probably when you post it has json but when you put it doesn't yeah in fact right there it doesn't even have it in this list here Python requests put json gotcha that guy put requests with json data json dot dumps still getting none I'm getting from the wrong half but I tried this first and it still didn't work already an adjacent formatted string you can pass it to put maybe that could be wrong and this one's either inaccurate or out of date or something but like we literally tried that and it didn't work these things are saying like you can use it there it's a server set thing I'm not sure what you mean do you consider adding a link to the PR in the YouTube do you consider adding a link to the YouTube video in the PR this was we could do that we'll remove put from this example I mean I don't think it's I don't know I don't like having it but is it misleading is it I don't know I mean you could use it to like update one of these objects I guess would be the real use for it I didn't think I mean in my mind it should work I think probably if we get the right thing it will work but I'm currently struggling to know what the right thing is and this gets kind of hard because you it's optional so it does say JSON here optional JSON data to send the body of the request and that's on put so that should work in my opinion or are you saying something in the server oops hold on now I did dumps though we definitely don't want that meant the request.json only works yeah but that's for reading the response right request you mean .json once you get a response or do you mean because I'm doing argument JSON not a .json and that should I mean as far as this code here is or docs I should say the docs here seem to think that should work but it also seems to think data should work but I also was failing to get data as well but I'm pretty sure that I have sent posts before or puts I mean maybe I have only done posts actually maybe I've only done posts I feel like puts should work the same way though I don't think it's necessarily a thing that should be removed but if there's a way to make it work the same because that's like I have an API where we use posts and puts and we send JSON in the body pretty short for both of them I thought and the delineation is like we do posts for creating a new object put for like updating an existing object but in both cases we send JSON in the body I wish I could look at my body before I send but we can't because we get stuck on our send one thing I do think that would be nice not necessarily removing the put altogether but if it would still respond I think this is telling me that it didn't respond right so if we could have code that's like if uploaded object is none return JSON response request wait is that a thing just yeah JSON response request and then we could just say message no data was sent and then it returns fine yeah but I am still confused about why we don't have our data should be there it's probably just coming through in the wrong place not in the body or something okay here's what you were talking about request.json I think I'm finally caught up with you again yeah okay I'm with you now this .json here doesn't work that would be okay I think it should allow put also and delete maybe does delete send bodies I'm pretty sure delete can send body as well it does look like we could also get it from bodies so theoretically we could say temporarily like duplicate this and say body JSON loads yeah sorry I'm 0 for 2 now with you telling me the exact answer and it going right over my head there we go okay yeah I'm totally caught up now this would be still a nice fix I think also though because if they do send whatever kind of method they send if it doesn't have a body it'd be nice to still respond to them with a valid response rather than a no response and then connection closed or whatever it is ultimately that it gets um alright I think we are going to be wrapping it up here pretty shortly the main thing I did not end up testing so far was the files we did not do any file uploading um and then we did I suppose some testing sort of tangentially with some of this stuff since we were using some forms on some of these the posting well in particular I guess we used query data more so than form data so we did not necessarily thoroughly test all of these although some of the testing we did probably touched some of these but there's probably more probably would be nice to do a bit more in depth there especially with the form data in particular so I think the plan for right now is I'm going to wrap it up for this evening I'm going to head out and then I will be back tomorrow morning at 10 am central time which is the normal time that I typically stream each week that is over on my own channel foamy guy underscore twitch on twitch or this foamy guy on YouTube I think although I don't know the URL off the top of my head sorry for that but I will post links in the discord the chat that's right below me right here live broadcast chat in the morning I'll post the links right when I'm getting ready to get started so those links will pop up with the to to the stream in the morning yeah thanks everybody for hanging out like I said as far as I know I believe I think Scott is back next week again don't hold me or him to that that's just I think so I think Scott's back in this time next week I'll still be around on Saturdays I hope everyone has a good rest of your Friday evening I'll see those of you that want to join me tomorrow then and thank you everybody else for watching thank you Michael for all the work on HTTP server as well as all the fixes live it's really nice to be able to go back and forth and ask questions and get answers even though it took me a little while to understand the answer sometimes super duper appreciate all your work on this library it really is lots of great work I've tried to mention a few times but yeah I really cannot say enough how much I appreciate your work on this it's super duper cool so thank you so much for all the work here thanks everybody for watching tune in next week for Scott and tune in tomorrow if you want to watch me do some more work I'll probably pick up where we left off here in the morning so tada for now see you later and thanks again for watching