Creating A Raspberry Pi Web Server For My Home!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so today what we're gonna do is we're gonna open up this package which contains a raspberry pi with all the different stuff that you need for a raspberry pi to actually use it i think uh i've never used a raspberry pi before but what we're gonna do with it is we're then gonna set it up to be like a local web server here in my house and we're gonna try to create an api for it as well using flask and python and then basically have like my own secret web server here where i can just uh connect to and like do different things through it even if i'm not in the house okay uh future cal here looking through the footage i just realized that i did a [ __ ] job explaining what we're gonna do so let's just fast forward this part and i can try to do a better job explaining it here no promises though so what we're gonna do today is like i said we're gonna set up a raspberry pi to use as a web server where i can host my own little private site for performing certain tasks in my home i will create a flask website slash api that i will be able to connect to from anywhere in the world that will be hosted on this raspberry pi my first use case will be to turn philips hue lights on and off remotely and right now i need to be connected to the right wifi to be able to turn my lights on and off from my phone which can sometimes be annoying because this often leaves me needing to reconnect to wi-fi and or disconnect from the current wi-fi that i'm on and connect to the wi-fi that my philips hue uses so i figured let's create a server that is always connected to the right internet and then host my own api on there that i can then create an app for so that i can then turn my lights on and off from wherever i am in the world so this is one of my first of many raspberry pi projects so let's go okay so this doesn't seem like it's working i wasn't i didn't have high expectations to be honest but now i've unboxed it and now we're gonna go into my office and then we're gonna actually try to get this thing to run yeah and let's see what we can do all right so i'm now in my office again and we're gonna try to again connect this but we're gonna connect it to this monitor here and see if we can get it up and running [Music] all right it is running and now we just need to get it to connect to the monitor as you can see we have the raspberry pi running right now we just need a mouse and a keyboard so that we can do things on the actual pi and then what we're going to do is we're going to actually build out a an api using ros using flask in python and try to see if we can create some certain commands and then connect this to a web server create some sort of domain there's a place where you can get some free domains and that's what we're gonna do and uh yeah we'll see how this actually goes uh so as it turns out that there was something wrong with the the raspberry pi or the os or something so i'm re-installing raspberry pi v as some sort of like imager it's basically just raspberry pi dot org downloads and then i'm basically downloading the version for windows and then i'm basically just fixing this thing so that i can run uh the raspberry pi again because it didn't it turned on but it doesn't actually turn on because there's some sort of error as per usual so now i'm just waiting for this and then we're gonna see if we can get it actually run okay so now i think it's done uh not sure if it's gonna work but we're gonna try it hopefully it will oh i think it's working all right so now what we're going to do is we're going to actually write the code for the flask api basically just get all that going on my main machines windows desktop once we have that running we're gonna actually install it onto the the raspberry pi and then we're gonna go through all the steps of like creating the actual web server and like hosting all that stuff on the raspberry pi but first of all we're just going to basically create something so that we can actually do something by basically using the api [Music] i think my bridge hue is not a unique ip address it's like local ip address so it's not something that you if you would google it up you wouldn't find my ip address based on that i don't think i think you can use a an actual unique ip address and you can find that for the bridge hue but i won't really need that i don't think because my raspberry pi will be connected to the same internet that my bridge here will be connected to so i don't think i'll actually need that so what we're gonna do next is we're gonna see if we can just connect the the raspberry pi and basically install this script onto that thing run it and see what happens oh and while we're on the topic this video is sponsored by kite kite is a free auto completion engine that uses machine learning to provide the completions which is what makes it stand out and also what makes it the best auto completion engine that i've used one of the most useful features is that kites completions are sorted or ranked by relevance instead of by popularity or by the alphabet this is possible because they're using machine learning to provide the completions it means that you will get suggested completions based on the code that you're actually writing and if you're writing code in python the copilot feature offers documentation lookup so you don't have to constantly google search function signatures and call patterns with kite you can actually write code up to 18 faster and who doesn't want to write code faster right so i highly recommend that you download kite and try it out it's completely free and supports up to 13 programming languages and 16 ides so just give it a go i know that you will like it because i love it okay so what i'm doing now is i'm just going to go to github i'm going to download the repo and then start trying to get it to work on the raspberry pi once we get it to work on the raspberry pi uh we can start to try to make these calls and once we've got that working then we're basically just gonna have to set up the web server and have it like be something that's constantly running on this raspberry pi [Music] do [Music] okay so this is the day after and uh yesterday where we got or where we ended up was basically upgraded the api now and i can turn all the lights on and i'm running it on my raspberry pi uh so now if we press enter on this command or on this site that i'm having up right now then that will turn all the lights on so let's just do that as you can see that light turned on and there's a light above me as well that turned on today what we're going to do is we're going to try to actually get this because right now i can't if i try to access this from my macbook pro then i can't actually get to the website or i can't get to the local host which means that we need to make it so that it's available publicly and that's basically what we're going to try to do and i'm not sure at this point what that actually is if it's that we need to run a web server or what what all the steps kind of mean i'm guessing that we need to do something called port forwarding uh which i'm not at all an expert in or i don't know at all too much about this so that's basically the goal for today is just to be able to access all these things through my uh macbook pro and then we're gonna see where we'll take this from there [Music] all right so future cal here again and like i said i had no idea what i was doing at this point but i was sort of on the right track here is what i spent the next eight hours struggling to figure out eight hours firstly i need to run the flask website on a server hosted on my raspberry pi to do that i need to set up something called apache and run an apache server on the pi and then run my flask app behind that apache server i don't quite know the ins and outs of how this works but i followed this really great tutorial after getting this to work i needed to do what i briefly mentioned before which was port forwarding which meant that i needed to log into my router and port forward from the router to the raspberry pi's ip address this is so that the raspberry pi server can be visible from outside of my local network again i don't quite know but luckily i didn't need to i just followed this great second article on how it works after that i just needed a domain name to connect to the site and i got a free one for this from noip dot com and that's it done okay i've spent the entire day just trying to get the web server up and running and now it is running and i've gotten everything to work so now that i can actually access uh and do different calls and do different things remotely and i don't have to be connected to my local wi-fi i can be connected to 4g or anything and i can turn on and turn off my lights via the philips hue api so this now works and what i'm going to do is i'm basically just going to finish this by putting this into the little box thing but yeah anyway now we're gonna just set this up for permanent use here in the apartment [Music] so [Music] all right so now i'm done with this whole thing i've got it running and i can now pull like actually do commands and the server is now public so that i can actually access this from anywhere so what i'm going to do is i'm going to show you kind of how that it actually works so as you can see now we're at the base of the project which is just going to say hello cal and that's where we go this is where we're running the flask api thing so now essentially what i'm going to do is i'm going to turn this light on and off via the api so we're going to type in light and then slash and then the id of this light which is going to be number three and then we're going to type in slash off and this should turn this light on off when i hit enter or ok so let's press ok and see if it works okay it says internal server but that's because what i'm trying to put out to this screen doesn't work i'm doing something wrong there but it did turn off the light and what we can do then do then is we can type in instead of off we can type in on and this should then turn back on and it does so that works we also have commands for turning on and off all of the lights so now we can do light slash off that should turn off all of the lights that i have so let's do that and as you can see here on the screen lights are off is the output that we get and as you saw this light's turned off and there's also a light above me that turned off i'm gonna turn them back on because i basically want them to be on oh it's so difficult to do this on the phone on enter all right now they're on okay so that means it works okay so that's it we now have a raspberry pi server running and we can do some basic url slash kind of api requests to it that will do certain things in my little apartment here so like turn on and turn off the lights and this is just a super basic project but i'm really excited about it and it's something that we can expand on in the future and i want to turn this into more of a series on my channel where i do like raspberry pi projects that i think will be really exciting and in other news i also have something else that i wanted to kind of tease in this video and that is on next tuesday so in the next video that i'll upload tuesday 8th of december i will announce something new that's really exciting and that i've been working on for a while and that's also part of the reason why i couldn't continue the daily uploads of videos because this project and daily uploads and all the other projects that i have going on it just took up too much time i wasn't able to do all of those things at once so i'm super excited about this project and i'm really happy with how it turned out and i wanted to save this announcement until the end of the video because i know that of all the people that watch this video not a lot of people will actually watch it all the way until the end so i kind of wanted this to be something where if you watch this to the end then i really appreciate you for doing that and so you will also be part of the smaller group of people that will actually hear this announcement at all all right so i'm gonna have to like stop it there because otherwise i'll get carried away and like reveal it before tuesday but anyway uh i really just want to say that i appreciate you for watching this video and i appreciate you for being subscribed and yeah i hope i'll see you in the next one on tuesday you
Info
Channel: Hallden
Views: 602,924
Rating: undefined out of 5
Keywords: Automation, coding, programming, finance, productivity, raspberry pi 4, raspberry pi projects, raspberry pi 4 projects, raspberry pi server, raspberry pi server for website, raspberry pi server nas, python projects, python programming ideas, python programming, raspberry pi projects for beginners, raspberry pi projects 2020, raspberry pi projects home automation, raspberry pi project ideas, raspberry pi projects python, raspberry pi projects tutorials, raspberry pi projects and more
Id: 6gkoDQUQSLc
Channel Id: undefined
Length: 15min 44sec (944 seconds)
Published: Fri Dec 04 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.