Easy Flask App Deployment with PythonAnywhere | Beginner's Step-by-Step Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm about to teach you how to deploy your very own flask application on the worldwide web that's it let's dive in welcome to a quick code with Josh special before I dive in do me a favor click the like And subscribe as that does help me a growing Channel smash that like button I'm about to help you deploy a flask application on the worldwide web guys I put this together cuz deployment drives me batshit crazy and I want to make it easy for you guys the stepbystep process today I'm going to put as a link in the description all right head down to the links in the description and you're going to get the step-by-step guide as well as all my other stuff I have available to you use those links those really help me all right enough chitchat over to deploying your web nope over to deploying your app on the web let's get it all right so the first order of business is you can see that I'm running my app here on my local server and this is like my to-do list flask application okay so everything I have here I have the code ready to go to be deployed on python anywhere all right now the next start of the process is my code is already on GitHub okay so if I head over here here's the code that I'm going to be using and your should be already on GitHub for this process okay the next step is I want us to head over to a place called python anywhere.com okay it's by anaconda and you can create a free account this whole thing is free now when we deploy the application today it'll be hosted on the web for free for 3 months okay after 3 months it'll be taken down or you could upgrade all right but since Heroku started charging us to deploy applications I'm using python anywhere all right and it works just great so here we are in the python anywhere dashboard now I'm going to go over to click on web and we are going to click add a new web app okay let's go through the setup process together I'll click next and I know that we're working on a flask application but I'm going to be detailed with this so it allows me to go through the steps I'm going to do manual configuration so right here I'm going to click manual configuration in the latest version of python right uh 3.10 is what I'm using here next and it's going to set everything up for us that's the first step okay go into web create a new web app and click manual configuration that's it you can see that I'm taking to this page and this is really the setup for our website okay but the next step of the process is we need to run a few console lines so I'm going to click on console and we're going to go to bash and I'm going to open up a new bash terminal this is a bit slower cuz it's on python anywhere but it does the trick just give it some time to load and some time to process your bash code okay so now that we're here I'm going to drop in some lines some commands that I need to run here in these commands I going to put a link in the description step by step for you guys all right so head on down there if there's anything that's out and you can get that so I'm going to paste in here I'm going to create a virtual environment okay and I'm naming it my virtual environment let's run that this takes a few seconds great okay the next step of the process is let's head back to your GitHub okay I'm going to go here and I'm going to get our URL cuz I want to clone this okay so we want to copy the repository that you trying to deploy right that flask application now that I have that I'll head back here and in our console I'm going to write get clone paste run see all right we've cloned it and I want to CD in into my folder here all right whatever your folder is that's what I want to get into so I'm going to CD my crud app all right we're in the app we are ready to go the next thing I need to do is right all the dependencies all the packages that you have on your flask application we want to install these all right so you should have a requirements text file already a part of your code let me show you real quick okay so over here I already have one um we should have put this together when we created your project but these are all the dependencies that I have within mine and I'm using okay to run this to create a requirements text file you can run in your terminal in vs code pip freeze greater than requirements. text I'll put it there okay um so we need to install all all of those back here on python anywhere I'm just going to type pip install - R and then the name of that file requirements.txt now it's going to go through and install all of those dependencies that I have on my application in order to upload it give it some time it'll do its thing awesome we're all done there okay so we're done in the console I can close that I'm just going to click the icon on the top left all right now I'm going to head back to web I want to get into my web app application and this is really that if we scroll down I see two things well I see a lot okay but the one I want to start off with is our code we need to give a source code path to this project all right so to get this path let's go up to our files all right and we need to open our folder okay so here is the git clone that we did so I'm going to click on that and I'm inside my folder I'm going to copy the pth half from right here the whole thing okay just copy that let's go back to your web scroll down to code and we're going to enter your path and I'm going to paste that and just click check okay that's it I'm going to keep that now I'm going to go into our wsgi file here we need to do some configuration so all of this can just go away delete that I still have my path copied I'm going to use it so I'm just going to paste it here for now okay um we need to put a little bit of code and I've included this in my template for you guys okay so let me drop this in here and this is just a little python all right now you can see my path I'm going to replace that and put that right into our path here okay um great so let me talk about what this really is back in GitHub okay if I go to my project you can see my python file is app.py okay this is really our flask application and if I open app.py within that I have the flask application itself app equals flask okay so this is what I'm trying to open and I'm trying to run this application over in Python anywhere it says from App this is our python file I would like to import the flask application app that's what we're doing here okay I'm going to click save that's all we need for this and we are going to go back now cuz there's one final step let's go back to our files and I'm going to open my Virtual environments folder inside let's open up the next virtual environment folder and I'm going to copy this entire path okay copy the whole thing I can go back to web and we're going to go down again right so previously we added in our code I gave my source code and we configured our wsgi configuration file I'm going to go down to Virtual environment and I'm just going to paste in what I just got check that's it you're ready to deploy the final step is Click deploy if we go to the top here I'm going to click reload and then we can click on your url right here okay whatever yours is let's click on it and you can see that we're taken to my deployed application right I can run it hello there and you can see it's working just how it should right if I say and you can see it's working just how it should if I type subscribe subscribe guys that's awesome now real quickly I do want to point out depending on your application if I go back here okay um in my actual application I'm not importing the database okay we have our static folder for CSS my templates for HTML and our app Pi my flask application is a to-do list so every time one of you guys opens my application you generate your own database so remember you need to upload based on what your project is guys you now have a deployed flask application on the worldwide web let's check it out we have task smash 2.0 that is awesome guys I hope that I helped you you know not get as much gray hair as I have because that drives me crazy if you found this valuable do me a favor and like this video okay it's a short video but I hope it helped you and those steps that I went through I made for you in the link in the description as well as all the other resources I have available to you guys anyways I'll see you around in my other episodes and if you missed my flask episode of an introduction to flask I'm going to link that here head on back and check that out as I guide you through how to create your very own flask application just like the one you saw in today's video all right enough chitchat until next week I'll see you then
Info
Channel: Code with Josh
Views: 1,990
Rating: undefined out of 5
Keywords: Flask app, Flask deployment, PythonAnywhere, PythonAnywhere tutorial, Python web hosting, Python web development, Web hosting tutorial, Flask tutorial, Flask web development, PythonAnywhere hosting, Deploy Flask app, Step-by-step guide, Beginner's guide, Easy deployment, Flask deployment guide, Python deployment, Web deployment, Beginner-friendly tutorial, Flask app tutorial, Deployment tutorial, Flask coding tutorial, Programming tutorial, Python development, Learn Flask
Id: Bx_jHawKn5A
Channel Id: undefined
Length: 10min 10sec (610 seconds)
Published: Tue Apr 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.