Flask Web Development in Python - 1 - Intro

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

Flask web framework for Python is introduced, with discussions on high-level web frameworks, hosting options, and server deployment using Digital Ocean, Linode, and PythonAnywhere.com. The video covers setting up a Flask application, transferring domain names, and connecting to servers via SSH and SCP.

Full Transcript

[Music] hello and welcome to my flask with Python tutorial video uh this is just going to be a quick introduction as well as setting up our environment for flask so first of all real quick what is flask what's a web framework um and then flas versus some of the other web Frameworks so web framework is just anything that makes the creation of a website really easy so just like programming languages Frameworks are high level or lowlevel um a very highlevel web framework that you're probably familiar with is WordPress so with WordPress you pretty much install WordPress and you have a website you just need to add the content to it um and then a low-level web framework I would accuse PHP of being a lowlevel web framework just the programming language itself then there's also like modules and stuff with PHP that will like add like a model view controller uh Paradigm to it and stuff like that but for the most part I would say PHP is low level and just for the record you know Python highle programming language C++ lowlevel programming language and basically what those levels mean are how far away from like raw code are we so that's why PHP raw machine code that is that's why PHP is kind of lowlevel for web development sake and then uh WordPress very high level you don't really code at all in WordPress so that's that now flask Django web Tupac Rock um there's definitely some others I'm forgetting these are all web Frameworks for python so how do we choose which one we want well D Jango in my opinion is more of a highle web framework now when you have something that's high level a lot of times you're going to get some bonuses out of it um so it's kind of like this the argument of you know should you should you learn how to um you know write a specific module or should you just use someone else's module so python uses do not repeat yourself Dr and I think sometimes people take Dr a little bit too far to the point where instead of do not repeat yourself it's do not repeat anything anyone's ever done ever and and I think that's a mistake you know if you don't know how to parse a website yourself you probably shouldn't use beautiful soup you should learn how to do it yourself and then maybe check out beautiful soup because beautiful soup might do it more efficiently than you but if you can't figure out how to do something in beautiful soup you can do it yourself same thing with really anything in programming or anything in life personally but um with flask Django and all these I would say d Jango is more high level now that's not to say Django's not confusing or you won't learn a lot in D Jango um you can and you can make Jango pretty basic but I like flask because it lends itself very easily to being very basic and you can add to it with modules and stuff like that that you get from other people and you can kind of increase the the level so to speak you can make flask a pretty high level web framework so I like flask so that's why we're going to be using um flask so with that let's go ahead and jump into getting an environment set up I don't really see the point in setting up a local environment for a website we want to host websites and run websites on host servers so that's what we're going to do in this series I don't really also see the point pretty much every tutorial including my own Django tutorial we create blogs I no I don't want to create blogs if you want to make a Blog use WordPress like WordPress is the best way to make blogs and so like for me like python anywhere or python programming. comom rather that's a that's WordPress and I probably won't ever change that because WordPress is so easy so anyway um with the host we're going to use you can use anything you can use Python anywhere.com you can use um lin.com digital locean it really doesn't matter python anywhere.com is going to like basically give you an instance instantly and then you've got other hosts like lenoe or digital ocean who are you're going to have to actually set up your uh your server so anyway let's go ahead and get into that okay so here we are uh this would be if you go to digital ocean.com uh and click on pricing these are all the um the beginning plans that they have but they do have some higher volume plans down here and then this would be lenoe and just for example like the linode 8 gab server currently $80 a month 8 gigs of RAM six cores 192 uh storage and if we switch over to dig I might have said uh digital lo I get them flipped all the time but anyway lenoe 8 gigs 192 and six and we come over here 8 gigs which is the identical two less cores and um less than half of the storage on um that server so just keep that in mind at least right now anything over the $20 a month plan so anything over a 2 GB of RAM you're better off on lenoe um and really I don't know why they always say just they just say hey you get two cores of a a processor like uh like how okay well we need to know a little bit about the processor but um there are I I saw a pretty recent uh benchmarking of the two servers uh with each other and they were pretty it CPU speed was pretty close but actually linode prevailed on uh quite a few things too but like I said just go with whoever has the cheapest uh prices at the time in my opinion but anyway um so what you would want to do if you don't already had have an account is sign up I would just do the $5 a month on digital ocean if you later on want to switch servers It's relatively easy uh to move because with a flask application you just move the flash directory you'll put the flash directory where it goes copy the database and move the database over um I'll show you guys a few on liners uh that you can put in maybe later on in a couple videos uh couple videos quite a few probably but a couple videos later um I'll show you guys a quick oneline function that will move a database for you so you can always just move it's really quick and easy and also I would just mention that when you swi switch servers and like hosts it really goes pretty darn quick I mean sometimes it it takes a little bit for some people to uh get resolution but for the most part it's a very fast fast thing to do so anyway on digital ocean $5 a month boom sign up make an account whatever I already have an account so uh that's what we're going to be using but obviously on linode it would be the same thing I also just wanted to quickly show um python anywhere.com because if you want to use Python anywhere you don't have to pay anything at all so you won't need a domain name and you won't need to uh buy a server at all so this is um where's their free plan I thought they had oh here we go it's right here okay was like oh my goodness they don't have a free account but anyway yeah so you can get this uh this limited account and you can make a single app so it be your username Python anywhere.com and you can make a flask application very basic you're not going to get a lot of processing ability but you could you could follow along in this tutorial video uh with a free account I don't want to use Python anywhere for this just simply because we can't set up our server like python anywhere is going to do it for us um I wouldn't yet recommend python anywhere for actually like hosting a real server on or or like a real website I do use Python anywhere as well I use them for a lot of heavy processing in Python but that's it I wouldn't want to host a website on them because they do they go down a fair amount of times they go down for like maintenance and stuff and also sometimes my scripts just stopped running I have no idea why but I wouldn't want a website on there um but to follow along more than fine and you won't have to set up you could just watch how to set it up or if you don't care you don't have to um but anyway we're going to be using digital ocean I actually already have a digital ocean account so I'm just going to spin up another digital ocean server here um so we'll do that so uh at least on digital ocean this is the process that you'll go through if you're on lenoe you'll go through a fairly similar process um so just bear with me so host name will'll call us anything we want for now we'll just call it um sentex tuts and I'm going to choose this the smallest one $5 a month or um .007 an hour um that's fine you can pick your region that you want um where okay so I forget uh which one I usually go with we'll go with New York anyway too for now um sometimes I have a connection issue with one of these servers I can't remember which one it was but anyway if it's this one we'll just redo it then select an image so like on digital ocean for example you can come to applications and you can pick like this one does Ruby on Rails D Jango on iunu where's flask digital ocean where is it um so it's not there but anyway um so we're just going to use a straight up Abu 14.04 64bit don't choose anything else um you can an i since this is just a a a tutorial I'm not going to enable backups but it's a good idea to have backups enabled you don't have to think about it just saying um anyway that's it for us so we just hit create droplet and we're all set it's going to make our droplet for us um on linode it's a really similar process you create you know you choose your your operating system Ubuntu 14.04 64bit make your name whatever you're good to go so I'm going to pause this I think while this is creating the droplet so this is almost done uh while we're waiting now I want to talk about briefly how we're going to connect to this so and then also we need to transfer a domain name into it um so for my uses here I'm on a Windows machine Windows does not do SCP very well s CP which stands for secure copy and paste Skype Skype makes my malare bites pretty angry sometimes NSA is tracking me man it's going ballistic on me right now anyway um where was I so on Windows I'm going to assume most of you guys are on Windows but obviously you could be on Mac or whatever the stuff I'm going to cover is Windows based but obviously on Mac you can do a lot of things too Mac has a much better SCP functionality than Windows does also you can use I prefer win SCP anyway is what I'm trying to get to um I like wi SCP uh it's a nice client that I like to use but you can also use if you're on Mac you can get filezilla um and then also I like to use putty now if you're on Mac again you don't even need a client to do SS but anyway if you're on Windows we're going to use putty um I'll show a quick example of putty this would be putty right here um P TTY Y and then also I like to use SCP which is here this droplet is taking forever it should not take this long I almost want to let me see it might even be done or something synx TS let's see if we can connect to it for whatever reason that that's taking like way too long normally these things spin up in like 2 seconds so you've got centax to and at least on digital ocean they email you a password and if you're on lenoe they're going to uh just ask you to create your password I'm going to check my phone here see if I got my password which I did and basically as soon as you log in it's going to be like hey you want to change your password and you will so anyway so I got my password uh so we're going to go ahead and try to log into our server real quick uh which is here and uh our host name is the IP address so we have not tied uh a a domain name to our server yet um so for now we use the IP address so the IP for uh putty will be this IP at least for me your IP will be completely different um let's see one okay U so we hit open and let's see if we can actually make it it's taking a while to make this connection so maybe the server really isn't done making yet normally these things spin up pretty quick I might end up having to uh redo this one apparently there's only 13 seconds remaining in the in the creation here um okay well while we're waiting on that we do actually have our IP address already so I guess I'll cover uh what you want to do with the IP here so my IP 162 243 5094 I have a domain name we're going to use for it's literally my name.com so we'll go over to uh our favorite godaddy.com where I have all my domains and what we want to do is there's two things we need to edit first of all we're going to go over here to this DNS Zone file and we want to change um the at Host uh and the IP address that it's going to point to so that's the first thing you need to edit now depending on who your host is this might vary uh but for for us um and for most hosts you're going to it's somewhere it's going to be edit DNS records okay and you just need to change where uh the uh domain name points so we'll hit okay all set I'll save my changes and then the other thing you need to do is you need to change your name servers so I think that was in settings and then name servers here on GoDaddy so then here is where you want to change your name servers I'm going to go ahead and hit custom here and we'll add our name servers now digital ocean is it done yet I think it's done now um so we'll go to that in a second but we need to go we'll go to DNS on digital ocean and I'm looking to get uh we'll add a domain [Music] here and this is this the domain so we're going to say uh my domain is harrisen Kinsley dcom and then just pick the droplet so this will be syx tou so it just automatically fills in the IP for you hit create domain and wait a moment and it will hopefully point that domain uh to our server and then you get these name servers here and then you're going to take these name servers so we'll just copy the first one come over to your uh domain registar add name server and then I want three so one two three and two and three so ns1 ns2 ns3 digital ocean.com hit okay and that's it we'll save those and it takes a little bit for these changes to take effect it's also going to take some time for the DNS servers to actually propagate and make the change because this was actually like cash parked on GoDaddy I think um so it might take a while uh generally it's pretty quick but it might end up being a little bit for you guys um usually it happens within like 20 minutes honestly for me so anyway uh just keep that in mind I'm going to close out of this and now uh we're going to go back to our droplets here synx TTS and let's make sure we can make a connection this time uh where's my IP there it is so come over to putty um session new session okay put in the IP uh Port 22 for SSH and you'll get this security alert basically what this is just saying is you don't have one of like you don't have this key right now um also if you change servers you'll get this exact same thing um we're pretty confident that there's no problem so I'm going to hit that's fine log in as root and then again on digital ocean they send you your root password on other servers uh or hosts they might allow you to make it up doesn't really matter what way they do it but anyway so we loging as root and then you'll take your password hold on as I type in this password they give you like a really weird one okay so as soon as you log in uh now they're going to make you change your password and they make you enter your current password again thanks guys and then your new password cool so now you're logged in rout at synx tuts and you basically like have nothing here it's just a simple web server pretty much um Sometimes some of the servers will actually come with quite a few things on it I don't really see too much let's see yeah so we don't really have anything installed here so then we need to actually we' got our our web server here and now we're ready to actually may like start building onto this web server um I'm going to cut the intro video here this is getting pretty long um but I do just want to also add uh show SCP real quick so this is uh SCP again if you're on if you're on Windows I like SCP best but if you're on Mac um then I probably you might have you know something you like um or like filezilla is a a decent a decent choice so here we go uh for SCP we want to connect here and I'll show you why we want SCP in a second yes same thing that just happened on uh putty there um so then here we have uh our SCP we've scpd into uh our server and here we are in the root directory and actually I think we ended up using uh SSH or even SFTP actually as we connected but anyway um here we are and these are all the just basically like gives you like a goey for your connection to your server it's um I like to do like commands and stuff in SSH and you can do um there's a lot of things I prefer to do just via SSH client um but as far as like finding stuff it's usually I don't know I'm just used to having some sort of goey so I'm going to be using SCP or win SCP and uh Putty for this tutorial series um the last thing um actually probably in the next few tutorials I'll talk about setting up SCP to work really nicely with Windows anyways um but we'll just do that as we go on so I'm going to cut the video here uh hopefully you guys have everything up to this point um it might take a while like I said for your server to actually uh propagate your new um domain name like for example Harrison Kinsley decom is not yet loading to anything but also we don't have any we don't have any server at all set up here it's just pointed to um it's just pointed to the server we don't have actually like anything like that will host the anything you know to the website so uh we'll we'll get there but probably by by the time you finish this video and then finish the next video hopefully it'll be resolved for you um so anyways uh that's it for this video if you guys have any questions or comments uh feel free to leave them below I'll put links to digital locean python anywhere and lode in the description if you happen to like uh the tutorial uh those those links are referral links and I will get hosting credit I use both of them so you will uh knock some pricing off of my hosting on either of those so um use those if you liked it otherwise you don't have to use my links but anyways um that's it stay tun in the next video

Original Description

Flask Playlist: http://youtu.be/mr90d7fp3SE?list=PLQVvvaa0QuDcOS4l8RCWh0olq_je0OKaP Hello and welcome to my introduction to Flask. Flask is a web framework for the Python programming language. A lot of people are curious to know what the differences of Flask and other developmental frameworks, especially compared to the Python frameworks. In this video, we cover what Flask is and how it compares to other frameworks, then we talk about how we set up our development server. We are going to be using a real server here for development, not a local setup. We do this because, if you are trying to learn web development, then you must be interested in a live, real website. The problem with working on a local instance is then you have to transfer everything to an actual server. You will find very quickly that things work very different when you leave your home computer. Hosts that I recommend: digitalocean.com: https://www.digitalocean.com/?refcode=d1c4c6e66979 (use these guys if you want just a small, cheap server $5/mo) linode.com: https://www.linode.com/?r=b417bc672ff52d6c055fd7a56e024939c667b0fd (use these guys if you think your website will get more than 1k visitors a day, I prefer Linode to DO.) pythonanywhere.com (use these guys for super easy setup, not recommended, however, for their downtimes, and some access restrictions as compared to your typical server.) Sample code: http://pythonprogramming.net/flask-web-development-tutorial/ http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video introduces Flask web development in Python, covering the basics of the framework, hosting options, and server deployment. Viewers learn how to set up a Flask application, transfer domain names, and connect to servers via SSH and SCP.

Key Takeaways
  1. Sign up for a Digital Ocean account
  2. Create a new Droplet with Ubuntu 14.04 64bit
  3. Transfer a domain name to the Droplet
  4. Use Putty and SCP to connect to the Droplet
  5. Log in to the Droplet and change the password
  6. Edit DNS Zone file to point domain name to server IP
  7. Change name servers on domain registrar
  8. Use name servers to point domain name to server
💡 Using a cloud server like Digital Ocean can simplify the process of deploying and managing a Flask web application, and provides a scalable and secure environment for development and production.

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →