1 00:00:00,660 --> 00:00:08,970 Hello, friends, in this video, we shall try and write our first flash application or less Hello World. 2 00:00:13,570 --> 00:00:18,310 Hello, World is invariably the first program that you write whenever you learn a new technology. 3 00:00:18,790 --> 00:00:24,680 So here also we shall see how to write or how to generate Hello World from our application. 4 00:00:25,900 --> 00:00:30,430 First and foremost, you are to import the last module. 5 00:00:32,000 --> 00:00:39,380 More specifically, you have to import the flask, a glass from the flask module that is mandatory, 6 00:00:40,730 --> 00:00:46,540 then you have to instantiate or you go to create an object of the flask. 7 00:00:46,580 --> 00:00:52,260 Plus that object of the flask class becomes our application object. 8 00:00:52,610 --> 00:00:55,680 It is an object for our WGI application. 9 00:00:56,180 --> 00:01:03,960 So these two steps are in the right in the beginning of your of our coal importing the flask Maryland 10 00:01:03,960 --> 00:01:06,380 class class and creating the object of. 11 00:01:08,670 --> 00:01:16,010 Now, you know that whenever an object of a class is instantiated, the constructor starts to work, 12 00:01:16,560 --> 00:01:20,240 so the class constructor also will be executed. 13 00:01:20,460 --> 00:01:29,370 And it takes one argument inside the underscore name, and it is the name of the current module that 14 00:01:29,370 --> 00:01:32,480 is the argument for the object. 15 00:01:33,720 --> 00:01:44,940 Then you are to use a function, root, root function of the last class is to be used to define the 16 00:01:44,940 --> 00:01:52,110 new order and map a particular view, function with the, you know, use the rule. 17 00:01:52,830 --> 00:01:59,970 So this root function is called as a decorator, which does the application which you are allowed to 18 00:01:59,970 --> 00:02:06,840 be, which when a particular order is given, which is the function that is to be executed, that association 19 00:02:06,840 --> 00:02:09,540 is defined by the root function. 20 00:02:10,080 --> 00:02:14,040 So this is the way in which this rule function is used. 21 00:02:14,370 --> 00:02:23,580 Eppy, the app, the name of the object of our Flast plus eppy, that route two arguments will be the 22 00:02:24,660 --> 00:02:25,130 rule. 23 00:02:25,670 --> 00:02:30,390 Rule is the other options are of course they are optional. 24 00:02:30,630 --> 00:02:37,650 They may not be appearing every time Ruri parameter represents the you are which is bound to a particular 25 00:02:37,650 --> 00:02:38,070 function. 26 00:02:39,000 --> 00:02:46,020 So FPP not route whichever you are you want if at all, for the root function. 27 00:02:46,020 --> 00:02:48,270 You, you want to pass certain parameters. 28 00:02:48,960 --> 00:02:51,840 Those parameters can be given as the options. 29 00:02:52,500 --> 00:02:55,170 So this is the syntax of the rule decorator's. 30 00:02:58,530 --> 00:03:07,420 After the rules are defined by the rules decorator, you have to run the application by calling the 31 00:03:07,680 --> 00:03:08,020 meter. 32 00:03:09,010 --> 00:03:10,540 So Eppy not run. 33 00:03:12,280 --> 00:03:16,390 It takes four parameters are for arguments, one is the host. 34 00:03:18,350 --> 00:03:25,150 The host on which your application will listen for the requests, the default is the local news. 35 00:03:25,760 --> 00:03:33,980 You can also identify the local lost by 127 one zero point zero one is the IP address of the local host. 36 00:03:34,940 --> 00:03:41,570 If you want this development server to be available from the external IP, then you can set it to zero 37 00:03:41,570 --> 00:03:42,080 zero zero. 38 00:03:44,220 --> 00:03:53,310 Board, no, we know that the Web server is bound to hostname and port names the default, what number 39 00:03:53,310 --> 00:03:54,060 is five thousand? 40 00:03:54,070 --> 00:03:55,200 You can change if you want. 41 00:03:56,160 --> 00:04:01,460 Debug option can be, you know, enabled or disabled depending on the requirement. 42 00:04:01,470 --> 00:04:03,050 What is the purpose of the debug option? 43 00:04:03,060 --> 00:04:10,260 I will tell you just afterwards and any other options that may be required to be passed to this Web 44 00:04:10,650 --> 00:04:11,160 server. 45 00:04:11,760 --> 00:04:15,420 So these are the four option four parameters that are required to this. 46 00:04:20,010 --> 00:04:27,410 So this is a sample code of a simple hello flask application, as I said in the beginning, to import 47 00:04:27,420 --> 00:04:39,680 the flask from the last module from flask, import, flask, OK, then create or declare an object applicable 48 00:04:39,690 --> 00:04:44,930 to flask takes one argument the name of the module in which it is named. 49 00:04:46,560 --> 00:04:48,360 Now this is the definition of the rule. 50 00:04:48,480 --> 00:04:52,230 I'm giving a slash at Eppy dot route. 51 00:04:53,190 --> 00:04:53,880 Not to this. 52 00:04:53,880 --> 00:04:56,190 You are in this function is mapped. 53 00:04:57,750 --> 00:04:58,820 What is the name of the function? 54 00:04:59,130 --> 00:05:01,290 I know what this is called a review function. 55 00:05:02,400 --> 00:05:06,000 When this you are it is given this function will be executed. 56 00:05:06,120 --> 00:05:10,230 And in turn what, what it will do, it will return this string. 57 00:05:10,260 --> 00:05:10,620 Hello. 58 00:05:11,010 --> 00:05:12,970 That will be rendered on your browser. 59 00:05:14,160 --> 00:05:23,530 This is of course the syntax or mechanism that you generally use to execute the module as the mean. 60 00:05:24,660 --> 00:05:31,040 Now when this Python script is executed, when you run this script by saying Python, hello, why? 61 00:05:31,050 --> 00:05:38,400 If this this script is named as PUA by Tom Hello Rajput, what happens? 62 00:05:39,030 --> 00:05:46,980 The server will start the WGI server development server will start and it will tell you in the python 63 00:05:46,980 --> 00:05:50,780 shell that it is running on STP. 64 00:05:51,360 --> 00:05:56,820 This localhost, the server starts running so the program is run. 65 00:05:57,750 --> 00:05:59,910 These are already started, started running. 66 00:06:00,360 --> 00:06:02,640 All you have to do now is to go to the browser. 67 00:06:03,360 --> 00:06:12,090 In that bar you either you can give one twenty zero zero one current five thousand or you can you localhost 68 00:06:12,130 --> 00:06:16,380 firefighters one and see what happens as soon as this. 69 00:06:16,410 --> 00:06:21,180 You are really given this one, this HelloWallet function will be executed. 70 00:06:21,240 --> 00:06:22,040 It will return. 71 00:06:22,050 --> 00:06:22,560 Hello. 72 00:06:22,920 --> 00:06:23,280 Hello. 73 00:06:23,280 --> 00:06:26,180 World as a string and it will be rendered on your browser. 74 00:06:26,790 --> 00:06:37,380 So that is the simplest way of generating or displaying world on your browsers page through the application. 75 00:06:41,690 --> 00:06:48,060 Now, you found that there is a debug option to the running method. 76 00:06:49,490 --> 00:06:55,190 Usually what happens when you are in a process of developing an application, you frequently want to 77 00:06:55,190 --> 00:06:56,680 make certain changes into it. 78 00:06:58,310 --> 00:07:05,180 So every time and are certain modifications or changes done, you may have to stop the server or when 79 00:07:05,180 --> 00:07:09,760 the program listing make the corrections and again run it. 80 00:07:10,700 --> 00:07:12,860 So this is a slightly tedious process. 81 00:07:13,310 --> 00:07:19,700 So you can avoid that by setting the deeper option to do so. 82 00:07:19,700 --> 00:07:25,850 If you step debugging, you want to prove no need to stop the program, stop the server chip, make 83 00:07:25,850 --> 00:07:27,980 the changes, save it and run it every time. 84 00:07:27,980 --> 00:07:33,270 You don't have to do this in each other, even if the server is running. 85 00:07:34,430 --> 00:07:38,220 You can go back to your code, make certain changes, save it. 86 00:07:38,570 --> 00:07:43,700 The server will automatically sense that a certain change has been done and it will automatically reload 87 00:07:44,600 --> 00:07:48,050 the contents of your backend program. 88 00:07:48,350 --> 00:07:56,840 So that is the benefit of setting the table is equal to as can be used when is set up or debug ep the 89 00:07:56,840 --> 00:08:00,350 name of the object that you want to prove and then run. 90 00:08:01,520 --> 00:08:05,050 Or you can use this debugging you want to do inside the Blackwaters. 91 00:08:06,050 --> 00:08:07,640 So what ways you can do it? 92 00:08:07,980 --> 00:08:14,630 The benefit of it is that while developing you don't have to face the hassles of stopping and starting 93 00:08:14,630 --> 00:08:15,050 like this. 94 00:08:18,830 --> 00:08:23,000 Lastly, when you say that when you run the program. 95 00:08:25,340 --> 00:08:31,340 In the development environment, the development environment is available only on the local machine 96 00:08:31,340 --> 00:08:34,680 on which the environment has been set up. 97 00:08:36,910 --> 00:08:44,320 Because the development support has been enabled, so when their support has been enabled, the support 98 00:08:44,320 --> 00:08:46,170 is available only on the local machine. 99 00:08:46,900 --> 00:08:55,150 If you want to make this application available to the external IP address, then what you have to do, 100 00:08:55,360 --> 00:09:03,130 you are to set another parameter hostage equal if you say is equal to zero zero zero zero, and if your 101 00:09:03,130 --> 00:09:07,870 computer is having a, you know, connection with the outside world. 102 00:09:09,420 --> 00:09:16,740 If it is having a static IP sort of thing, then this application, the application that you have written, 103 00:09:16,740 --> 00:09:23,580 may be available or will be available to the externally external environment so that your server will 104 00:09:23,580 --> 00:09:25,980 become an externally visible server. 105 00:09:26,970 --> 00:09:33,000 So these activities now, I will practically demonstrate in front of you so that you will be able to 106 00:09:33,000 --> 00:09:37,610 find out how exactly to write a hello world application so far. 107 00:09:38,810 --> 00:09:41,870 We have successfully installed flask. 108 00:09:42,990 --> 00:09:51,660 In our virtual environment now, we shall write a simple hello world application using Flast, so first 109 00:09:51,960 --> 00:09:59,430 line is required to import the flask module into our application. 110 00:10:00,510 --> 00:10:03,510 Next is to create a flask object. 111 00:10:04,790 --> 00:10:12,860 Which takes the constructor of the flask plastic's one argument, which is the name of the current module 112 00:10:13,430 --> 00:10:17,140 and that is retrieved by that will underscore the name of the school. 113 00:10:18,820 --> 00:10:22,020 Then you are to use the rope. 114 00:10:23,440 --> 00:10:26,530 Method of the flask object. 115 00:10:28,340 --> 00:10:35,840 What Israel is doing is route is called the corridor, which tells the flask server, which is the. 116 00:10:37,640 --> 00:10:40,750 You know, function, which is associated with this, you are. 117 00:10:41,810 --> 00:10:51,140 So which means that this forward slash you want in front of the record, in the room means that this 118 00:10:51,140 --> 00:10:54,480 forward slash is attached to this function. 119 00:10:54,770 --> 00:10:58,070 So if I invoke the server and you. 120 00:10:59,150 --> 00:11:02,720 This forward slash in front of the name of the server. 121 00:11:04,090 --> 00:11:06,240 Then this function will be executed. 122 00:11:07,000 --> 00:11:07,510 So. 123 00:11:08,930 --> 00:11:09,650 When this. 124 00:11:11,040 --> 00:11:17,730 Script will be run, the AP did maybe not run, run function, then Metalious available to this flask 125 00:11:17,820 --> 00:11:25,620 object that will be executed and accordingly, whichever path that you mention in the you are in the 126 00:11:25,620 --> 00:11:27,960 associated function will be called. 127 00:11:28,410 --> 00:11:37,830 So what I am going to do is I run this application from the python, from the Python prompt will show 128 00:11:37,830 --> 00:11:44,940 me that the server is running and then we will open the browser to see the world message that is being 129 00:11:44,940 --> 00:11:45,330 printed. 130 00:11:46,020 --> 00:11:46,800 So this was. 131 00:11:47,710 --> 00:11:50,740 The script of the Hello World application. 132 00:11:53,200 --> 00:11:54,070 Now, Norwegian. 133 00:11:55,190 --> 00:12:00,310 Start the application, our virtual environment is in the flask in redirect. 134 00:12:00,370 --> 00:12:03,560 So first we have to activate it by seeing. 135 00:12:07,570 --> 00:12:14,180 Activity, which is in the scripts folder of the class in the Virtual Environment Directorate. 136 00:12:14,650 --> 00:12:15,790 So it will be activated. 137 00:12:17,810 --> 00:12:20,490 Then we are to run the script out by. 138 00:12:24,480 --> 00:12:27,110 So if I press enter, what will happen? 139 00:12:30,580 --> 00:12:36,910 The message will be they're telling me that the server is running on. 140 00:12:37,960 --> 00:12:41,800 One twenty seven point zero one zero zero one zero point one. 141 00:12:42,830 --> 00:12:48,950 That is the address of the localhost, the default for these five thousand, so on this, the server 142 00:12:48,950 --> 00:12:49,400 is running. 143 00:12:50,060 --> 00:12:50,780 So if I. 144 00:12:52,930 --> 00:12:59,680 Go to the browser, give this URL, I should be able to see the hello world message being printed. 145 00:12:59,950 --> 00:13:05,550 So let us open the browser and give the Yoran, as you know, being displayed there. 146 00:13:06,400 --> 00:13:12,730 Now we shall see how the debugged support can be enabled in the flask application. 147 00:13:13,790 --> 00:13:16,010 Actually, our application is right now running. 148 00:13:17,120 --> 00:13:21,410 At the U.N., you are so I will first stop it by control. 149 00:13:24,370 --> 00:13:25,000 And then. 150 00:13:26,590 --> 00:13:30,910 Inability work, supervising the work equal to two. 151 00:13:39,560 --> 00:13:42,050 And ran the application. 152 00:13:43,570 --> 00:13:47,960 You see, there are certain changes in the output that is being displayed. 153 00:13:48,430 --> 00:13:54,550 It says that the weather is active and it is the application is running on the same. 154 00:13:54,550 --> 00:13:55,010 You are. 155 00:13:56,790 --> 00:14:03,220 OK, so if you again go back to this localhost Quillen 5000, and it will again show you the whole. 156 00:14:05,450 --> 00:14:10,460 So the hello world is displayed now, what is the effect of this debuggers equal to? 157 00:14:12,340 --> 00:14:15,250 If the devil is not set equal to two. 158 00:14:16,230 --> 00:14:22,890 And if the application is running after the app while the application is running, if you make any changes 159 00:14:22,890 --> 00:14:24,060 to the Python script. 160 00:14:25,240 --> 00:14:32,650 Then for every change that you may have, you may want to make to this fight on application, you know, 161 00:14:32,680 --> 00:14:37,020 to stop this or make the changes, restart the server and then. 162 00:14:38,400 --> 00:14:43,660 Open the browser now that they're debug is through the work, support is enabled. 163 00:14:44,160 --> 00:14:47,440 What you can do while the server is running itself. 164 00:14:47,460 --> 00:14:49,890 You can do whatever changes you want. 165 00:14:51,040 --> 00:14:56,540 Those changes will be automatically refreshed without you having to stop and restart the server. 166 00:14:57,030 --> 00:14:59,020 That is the advantage of Diebel. 167 00:15:00,230 --> 00:15:05,900 Our application is already running in the world more than the work is set equal to do you know what 168 00:15:05,900 --> 00:15:06,390 I will do? 169 00:15:06,590 --> 00:15:08,600 I will make certain changes here. 170 00:15:11,820 --> 00:15:12,840 Something like this. 171 00:15:19,310 --> 00:15:21,110 And save this. 172 00:15:22,620 --> 00:15:24,900 As soon as I see you, you see that. 173 00:15:26,300 --> 00:15:31,580 That is saying detect change in the script, and it is reassuring it. 174 00:15:33,970 --> 00:15:35,710 So this is what happens when you. 175 00:15:36,770 --> 00:15:43,220 And they will debate more now if I go back to the browser and just refresh it, I should be able to 176 00:15:43,220 --> 00:15:45,950 see the Halo tutorial point instead of Hellewell. 177 00:15:47,460 --> 00:15:52,830 You do not have to stop this or make the changes and then again relaunch it. 178 00:15:54,080 --> 00:15:56,780 So it has already reloaded the script. 179 00:15:57,860 --> 00:15:59,120 And just refresh this. 180 00:16:01,440 --> 00:16:04,510 That is why the changes have been automatically incorporated. 181 00:16:04,530 --> 00:16:11,610 So this is how the debug effect, neocortical through, affects the behavior of the. 182 00:16:12,750 --> 00:16:13,230 Server.