1 00:00:00,000 --> 00:00:01,610 [No Audio] 2 00:00:01,611 --> 00:00:04,986 Hey, welcome to a very informative lecture, 3 00:00:04,987 --> 00:00:07,876 especially about those who are interested in 4 00:00:07,877 --> 00:00:10,350 building web applications with Python. 5 00:00:10,930 --> 00:00:13,540 As you may know, Python is used 6 00:00:13,541 --> 00:00:17,626 for different purposes, from automating routine tasks 7 00:00:17,627 --> 00:00:19,764 in your job, let's say you want to 8 00:00:19,765 --> 00:00:24,010 generate PDF reports, automatically send automated emails, etc. 9 00:00:24,011 --> 00:00:26,012 Then you can use Python for Data 10 00:00:26,013 --> 00:00:29,522 Analysis and Visualization, Data Science and Machine 11 00:00:29,523 --> 00:00:32,466 Learning, but also for Web Development. 12 00:00:32,467 --> 00:00:36,988 So, building web applications with Python. And here is 13 00:00:36,989 --> 00:00:39,664 where, I would like to stop and explain you 14 00:00:39,665 --> 00:00:43,542 how exactly Python can be used in Web Development 15 00:00:43,543 --> 00:00:47,584 and, what Python Web Frameworks you should use. 16 00:00:47,585 --> 00:00:51,114 So I just mentioned the word, Web Framework. 17 00:00:51,115 --> 00:00:53,194 So what is a Web Framework? 18 00:00:53,195 --> 00:00:56,372 Well, with Python, you can build applications either 19 00:00:56,373 --> 00:01:00,532 by using plain Python or by using one 20 00:01:00,533 --> 00:01:03,464 of the Python Web Frameworks, which are basically 21 00:01:03,465 --> 00:01:07,110 Python libraries that you install with pip. 22 00:01:07,111 --> 00:01:10,142 And these web frameworks make it easier 23 00:01:10,143 --> 00:01:13,534 to write web applications using Python. 24 00:01:13,535 --> 00:01:16,332 Now, I can tell you that creating a 25 00:01:16,333 --> 00:01:19,916 web app, without using one of these Web 26 00:01:19,917 --> 00:01:23,586 Frameworks, is like reinventing the wheel. 27 00:01:23,587 --> 00:01:26,412 Because if you don't use a Web Framework, you 28 00:01:26,413 --> 00:01:30,272 basically have to rewrite, all the code that the 29 00:01:30,273 --> 00:01:35,046 authors wrote, the authors of these Web Frameworks wrote. 30 00:01:35,047 --> 00:01:38,912 So instead we just install these web frameworks and then 31 00:01:38,913 --> 00:01:43,114 we use that code, that is inside the Web Frameworks. 32 00:01:43,115 --> 00:01:46,922 And that code is usually things like, handling http 33 00:01:46,923 --> 00:01:49,978 requests, and delivering web pages on the browser. 34 00:01:49,979 --> 00:01:53,490 So routine low level tasks. 35 00:01:54,230 --> 00:01:56,862 But instead of dealing with this task, 36 00:01:56,863 --> 00:01:59,752 we want to focus on building the 37 00:01:59,753 --> 00:02:03,400 functionality, the practicality of our web application. 38 00:02:03,401 --> 00:02:06,268 So creating the input boxes, for example, for 39 00:02:06,269 --> 00:02:09,836 our forms, sending users from one web page 40 00:02:09,837 --> 00:02:12,300 to the other, so things like that. 41 00:02:12,301 --> 00:02:15,370 So you should use a Web Framework. 42 00:02:15,371 --> 00:02:18,176 So I guess we have clarified that point, 43 00:02:18,177 --> 00:02:21,110 that you should use one Web Framework. 44 00:02:21,111 --> 00:02:23,248 Now, the next question is which all 45 00:02:23,249 --> 00:02:25,740 the Web Frameworks you should use? 46 00:02:26,750 --> 00:02:29,702 Well, there are many Web Frameworks for Python, 47 00:02:29,703 --> 00:02:33,268 but I'll only focus on three of them, 48 00:02:33,269 --> 00:02:37,390 which is Flask, Django and JustPy. 49 00:02:37,400 --> 00:02:39,490 [No Audio] 50 00:02:39,491 --> 00:02:41,194 Let's start with Flask. 51 00:02:41,195 --> 00:02:44,470 Flask is a Web Framework usually 52 00:02:44,471 --> 00:02:48,798 targeted for building small web applications. 53 00:02:48,799 --> 00:02:53,592 For example, let's say you just want to build a 54 00:02:53,593 --> 00:02:58,652 small translator that translates, from one language to another. 55 00:02:58,653 --> 00:03:00,710 Think of Google Translate. 56 00:03:01,850 --> 00:03:04,652 If you just want that web application where people go 57 00:03:04,653 --> 00:03:09,152 to your domain, let's say translator.com, and you just have 58 00:03:09,153 --> 00:03:12,816 those two boxes there, people will type in the text 59 00:03:12,817 --> 00:03:15,968 in one language in the first box and get the 60 00:03:15,969 --> 00:03:19,260 results, so the translation in the other box. 61 00:03:19,790 --> 00:03:21,572 So that would be a small app. 62 00:03:21,573 --> 00:03:24,964 Another example would be an app where you 63 00:03:24,965 --> 00:03:29,386 convert, let's say, JPG images to PNG images. 64 00:03:29,387 --> 00:03:32,933 So people upload an image in JPG or vice versa. 65 00:03:33,570 --> 00:03:37,242 So Flask handles all those uploading 66 00:03:37,243 --> 00:03:40,426 and processing on the background. On the background, 67 00:03:40,427 --> 00:03:43,012 of course, you'll probably need an 68 00:03:43,013 --> 00:03:46,002 image processing library, besides Flask. 69 00:03:46,003 --> 00:03:48,156 So you'll have to install, pip install 70 00:03:48,157 --> 00:03:50,876 flask, and maybe pip install cv2. 71 00:03:50,877 --> 00:03:54,812 So OpenCV to do the processing, but the serving to the 72 00:03:54,813 --> 00:03:58,182 website, to the web app, will be done with Flask. 73 00:03:58,183 --> 00:04:02,030 So Flask will get the original image and it will 74 00:04:02,031 --> 00:04:06,854 get the output image from OpenCV, and it will serve 75 00:04:06,855 --> 00:04:10,300 the output image for download on your web app. 76 00:04:10,850 --> 00:04:13,322 So these are small web apps. 77 00:04:13,323 --> 00:04:14,676 Now, don't get me wrong. 78 00:04:14,677 --> 00:04:16,084 With Flask, you can also 79 00:04:16,085 --> 00:04:19,418 create, bigger web applications. 80 00:04:19,419 --> 00:04:22,874 And what I mean by bigger web applications, bigger 81 00:04:22,875 --> 00:04:25,672 web apps, I mean things like, let's say you 82 00:04:25,673 --> 00:04:31,016 have a blog website, where you add blogs every 83 00:04:31,017 --> 00:04:33,544 week or every two days or so. 84 00:04:33,545 --> 00:04:36,380 So you have maybe several authors who write 85 00:04:36,381 --> 00:04:37,766 content for your blog, 86 00:04:37,767 --> 00:04:40,033 [No Audio] 87 00:04:40,034 --> 00:04:42,010 for that blog website. 88 00:04:42,011 --> 00:04:46,252 So we're going to have different blogs, and all 89 00:04:46,253 --> 00:04:49,600 these blogs have to be saved in a database. 90 00:04:49,870 --> 00:04:52,272 Now, Flask can do this, of course, 91 00:04:52,273 --> 00:04:55,260 but Django would do this better. 92 00:04:56,190 --> 00:04:59,456 Django would do this better because, it is 93 00:04:59,457 --> 00:05:03,332 easier to work with databases with Django, because 94 00:05:03,333 --> 00:05:06,586 it has a better level of abstraction. 95 00:05:06,587 --> 00:05:08,532 So with Flask, you can also do this 96 00:05:08,533 --> 00:05:11,508 with Flask, but it's more work, you have 97 00:05:11,509 --> 00:05:14,718 to do more routine tasks for Flask. 98 00:05:14,719 --> 00:05:17,272 And Django would also allow you to 99 00:05:17,273 --> 00:05:21,944 add more apps, in that website project. 100 00:05:21,945 --> 00:05:25,544 So we took the example of blogs, you 101 00:05:25,545 --> 00:05:27,452 will have blogs in your website, but maybe 102 00:05:27,453 --> 00:05:29,450 you want to add another feature. 103 00:05:29,451 --> 00:05:31,852 Let's say you want to add a translator there. 104 00:05:31,853 --> 00:05:34,530 So Django can also build a translator, 105 00:05:34,531 --> 00:05:37,772 on top of that existing website. 106 00:05:37,773 --> 00:05:39,952 But if you just want to build a 107 00:05:39,953 --> 00:05:45,030 translator alone, then Django would be an overkill. 108 00:05:45,031 --> 00:05:46,752 What do I mean by that? 109 00:05:46,753 --> 00:05:50,070 By that I mean that for smaller web apps, 110 00:05:50,071 --> 00:05:53,460 Django takes more work to set it up. 111 00:05:53,461 --> 00:05:57,892 To set up a Django project, it takes more work. 112 00:05:57,893 --> 00:05:59,188 But once you set up a 113 00:05:59,189 --> 00:06:02,566 Django project, then things go smooth. 114 00:06:02,794 --> 00:06:05,512 But for smaller apps, it's good 115 00:06:05,513 --> 00:06:07,976 to just create a Flask application. 116 00:06:07,977 --> 00:06:09,784 It's very easy to create one. 117 00:06:09,785 --> 00:06:14,137 So that is the difference between Django and Flask. 118 00:06:14,138 --> 00:06:16,322 Now here comes JustPy. 119 00:06:16,323 --> 00:06:18,978 JustPy is a very new Framework. 120 00:06:18,979 --> 00:06:22,258 And why did I include JustPy 121 00:06:22,259 --> 00:06:24,914 in this, set of three Web Frameworks? 122 00:06:24,915 --> 00:06:27,692 Now, JustPy is quite special. 123 00:06:27,693 --> 00:06:29,248 What do I mean by that? 124 00:06:29,249 --> 00:06:33,072 Well, with Flask and Django, you also need to know 125 00:06:33,073 --> 00:06:37,494 HTML and CSS, to be able to build web apps. 126 00:06:37,495 --> 00:06:39,952 Because every web page that you see 127 00:06:39,953 --> 00:06:44,378 on internet, it's built on HTML. 128 00:06:44,379 --> 00:06:49,796 So all the text and input boxes and buttons, all 129 00:06:49,797 --> 00:06:53,124 those are built in HTML code, which is very easy. 130 00:06:53,125 --> 00:06:55,002 So don't get scared about HTML. 131 00:06:55,003 --> 00:06:57,128 It's a very easy language to learn. 132 00:06:57,129 --> 00:06:59,912 But I'm just saying that, you cannot create the 133 00:06:59,913 --> 00:07:02,606 front end of a web page with Python. 134 00:07:02,607 --> 00:07:06,376 So HTML is for the front end and then CSS is 135 00:07:06,377 --> 00:07:11,970 to beautify, to prettify, the look of these HTML elements. 136 00:07:11,971 --> 00:07:15,756 So the text boxes, the text, the colors, all 137 00:07:15,757 --> 00:07:19,490 these can be made to look nicer with CSS. 138 00:07:19,491 --> 00:07:21,808 So CSS is also a language which 139 00:07:21,809 --> 00:07:23,408 is also very easy to learn. 140 00:07:23,409 --> 00:07:26,182 So you'll have to write some CSS and HTML 141 00:07:26,183 --> 00:07:30,246 code and save that code in HTML and CSS 142 00:07:30,247 --> 00:07:35,076 files respectively, and put those files inside your web 143 00:07:35,077 --> 00:07:37,914 app, be it in Django or Flask. 144 00:07:37,915 --> 00:07:40,720 Now, here is where JustPy comes in. 145 00:07:41,490 --> 00:07:44,586 JustPy allows you to create web apps 146 00:07:44,587 --> 00:07:48,110 without writing any line of HTML and CSS. 147 00:07:48,850 --> 00:07:50,232 JustPy is very new. 148 00:07:50,233 --> 00:07:52,622 It's a new Framework, Web Framework. 149 00:07:52,623 --> 00:07:55,582 And as I said, the good thing about JustPy 150 00:07:55,583 --> 00:07:57,304 is that you don't have to write HTML and 151 00:07:57,305 --> 00:08:02,498 CSS because, JustPy has some specific Python objects. 152 00:08:02,499 --> 00:08:06,258 Let's say it has a div to create these divisions, 153 00:08:06,259 --> 00:08:08,524 where you can put text and things like that. 154 00:08:08,525 --> 00:08:10,080 Or it has a button object. 155 00:08:10,081 --> 00:08:12,880 So Python button object to create 156 00:08:12,881 --> 00:08:14,848 a button on the web page. 157 00:08:14,849 --> 00:08:17,168 Of course, the downside of this is that, you are 158 00:08:17,169 --> 00:08:22,554 not very flexible, as you'd be with Flask and Django. 159 00:08:22,555 --> 00:08:24,042 Again, I would say JustPy 160 00:08:24,043 --> 00:08:26,682 is also for small web applications. 161 00:08:26,683 --> 00:08:29,412 If you want to build a blog website with 162 00:08:29,413 --> 00:08:33,950 lots of content, JustPy is not the best choice. 163 00:08:34,630 --> 00:08:37,118 It doesn't work very well with databases 164 00:08:37,119 --> 00:08:40,894 as much as Django does or Flask. 165 00:08:40,895 --> 00:08:43,336 But again, if you just want to build a 166 00:08:43,337 --> 00:08:45,532 small web app and you don't know CSS or 167 00:08:45,533 --> 00:08:49,770 HTML, then JustPy could be better than Flask. 168 00:08:49,771 --> 00:08:52,060 So that was an overview of 169 00:08:52,061 --> 00:08:54,754 three Web Frameworks for Python. 170 00:08:54,755 --> 00:08:57,356 Now, all these three Web Frameworks are 171 00:08:57,357 --> 00:08:59,776 covered in the course, in this course. 172 00:08:59,777 --> 00:09:01,952 So we will build at least one web 173 00:09:01,953 --> 00:09:06,214 app, with each of these three Web Frameworks. 174 00:09:06,215 --> 00:09:09,712 And it may be tempting that you want to 175 00:09:09,713 --> 00:09:13,012 watch only the videos, of the Web Framework that 176 00:09:13,013 --> 00:09:16,442 you like, but I would recommend that you don't 177 00:09:16,443 --> 00:09:18,938 skip any of these Web Frameworks. 178 00:09:18,939 --> 00:09:21,012 I'm saying that because if you want to do 179 00:09:21,013 --> 00:09:24,440 Web Development with Python, then it's a good idea 180 00:09:24,441 --> 00:09:27,886 to be exposed to different Web Frameworks. 181 00:09:27,887 --> 00:09:30,990 Each of the Frameworks does things differently. 182 00:09:30,991 --> 00:09:36,318 So you will learn a good deal of, Web Development. 183 00:09:36,319 --> 00:09:38,492 For example, Flask does things a bit more 184 00:09:38,493 --> 00:09:41,532 low level and row, and that helps you 185 00:09:41,533 --> 00:09:44,802 understand Web Development from a deeper perspective. 186 00:09:44,803 --> 00:09:48,882 But then you'll learn about Django and you'll appreciate 187 00:09:48,883 --> 00:09:52,432 the high level of abstraction that Django has. 188 00:09:52,433 --> 00:09:55,056 You'll appreciate how easy it is to make 189 00:09:55,057 --> 00:09:57,872 changes in your web apps, when you use 190 00:09:57,873 --> 00:10:01,650 Django because of that high level usability. 191 00:10:01,651 --> 00:10:04,628 So Django hides some things from you 192 00:10:04,629 --> 00:10:07,828 which makes things easier, but you will 193 00:10:07,829 --> 00:10:09,796 not understand some of those things. 194 00:10:09,797 --> 00:10:12,458 So that's why you should also learn Flask. 195 00:10:12,459 --> 00:10:15,268 And also JustPy is very fun to learn. 196 00:10:15,269 --> 00:10:19,208 And I would recommend JustPy, especially for someone who 197 00:10:19,209 --> 00:10:22,702 is not interested to become a core Web Developer. 198 00:10:22,703 --> 00:10:26,568 So maybe you are a Data Analyst, but you 199 00:10:26,569 --> 00:10:28,188 just want to make a web app where you 200 00:10:28,189 --> 00:10:32,124 show some data, some visualization on that web app. 201 00:10:32,125 --> 00:10:34,556 In that case, JustPy could 202 00:10:34,557 --> 00:10:36,866 be actually the best choice. 203 00:10:36,867 --> 00:10:39,570 But if you want to be a pure web developer, 204 00:10:39,571 --> 00:10:42,354 then you want to learn Django and Flask. 205 00:10:42,355 --> 00:10:44,236 And then when you have to build a web 206 00:10:44,237 --> 00:10:46,956 app, you can just pick one of the Web 207 00:10:46,957 --> 00:10:50,012 Frameworks which is best for that project, 208 00:10:50,013 --> 00:10:53,570 or maybe the web framework that you know better, why not? 209 00:10:53,571 --> 00:10:55,966 I hope this helps and I'll talk to you later.