1 00:00:00,570 --> 00:00:08,370 Hello, friends, in this video, we shall discuss the different HTP matters and how they are used along 2 00:00:08,370 --> 00:00:10,050 with the flask application. 3 00:00:14,110 --> 00:00:18,980 AWB stands for hypertext transfer protocol. 4 00:00:20,650 --> 00:00:29,230 This is an application protocol and it is used for distributing Calavera to hypermedia information systems. 5 00:00:30,310 --> 00:00:39,640 HDB is the foundation of all the data communication activities in the W w w are World Wide Web hypertext 6 00:00:40,390 --> 00:00:48,490 is a structured text that uses the logical links between the nodes that are containing the text. 7 00:00:50,080 --> 00:00:55,270 This protocol is to exchange or transfer the hypertext. 8 00:00:55,270 --> 00:01:02,430 Its name itself suggests that it is used to exchange or transfer the hypertext. 9 00:01:02,770 --> 00:01:05,050 There's a difference between the text and hypertext. 10 00:01:06,550 --> 00:01:15,010 SCDP defines the methods to indicate the desired action to be performed on whatever resource is to be 11 00:01:15,120 --> 00:01:18,440 communicated, to be used for communication resource. 12 00:01:18,510 --> 00:01:26,700 Maybe this is maybe a file or a resource maybe and the output of some executable program. 13 00:01:27,370 --> 00:01:36,100 So any such resource may be exchanged between one node to the other node and that exchange or transfer 14 00:01:36,100 --> 00:01:46,210 is controlled by this EDP to begin with, HDB 1.0 was the specification that was defined and in which 15 00:01:46,420 --> 00:01:54,850 it started with two methods get and post, let alone the revision of HTP specifications. 16 00:01:55,600 --> 00:02:03,450 But it should be one point, one error, some additional methods like put, delete, trace and connect. 17 00:02:04,510 --> 00:02:14,830 So all in all, there should be 1.0 provided to the most two most popular HGP methods plus get and post. 18 00:02:15,580 --> 00:02:17,970 But then the other matters are also prevalent. 19 00:02:18,250 --> 00:02:25,300 Let us see the use and the definitions of all these methods, one by one. 20 00:02:31,030 --> 00:02:40,450 As I said, the gate and the Post are the two most commonly used CETP methods of which gate is the default 21 00:02:40,460 --> 00:02:40,810 method? 22 00:02:41,590 --> 00:02:47,380 It is, it sends the data in the plane unencrypted manner most. 23 00:02:47,710 --> 00:02:50,130 As I say, it is the most commonly used method. 24 00:02:51,040 --> 00:02:56,800 Post method is another commonly used method, which was in fact the one of the earliest methods that 25 00:02:56,800 --> 00:02:58,000 were defined. 26 00:02:58,480 --> 00:03:07,300 It is used to send the original data to the server, especially if you have a stable form and the form 27 00:03:07,300 --> 00:03:14,200 that has to be submitted to the server, then it is packaged inside a post request. 28 00:03:14,950 --> 00:03:22,180 It is used to send the e-mail form letter to the server, the data server data that is, that the server 29 00:03:22,180 --> 00:03:26,980 receives by the post method is not gatecrashed by the server. 30 00:03:26,980 --> 00:03:35,780 Unlike the gate method where the server remembers the data that was earlier received by the post, data 31 00:03:35,800 --> 00:03:37,260 is not retained by the server. 32 00:03:37,270 --> 00:03:38,640 That is another advantage of that. 33 00:03:38,680 --> 00:03:44,010 Using the post with the additional methods that were introduced in HDB. 34 00:03:44,020 --> 00:03:46,630 One point one include a header method. 35 00:03:47,950 --> 00:03:53,800 It is more or less the same as get, but it doesn't have the response body. 36 00:03:54,100 --> 00:04:01,500 So which means what if the server receives the request by the method? 37 00:04:01,510 --> 00:04:03,370 It doesn't have to send the response. 38 00:04:04,560 --> 00:04:08,560 Only the header part of the EDP is received from the client. 39 00:04:09,640 --> 00:04:13,770 But the method is again a very useful variation. 40 00:04:14,110 --> 00:04:19,090 It replaces all the current representations of the target resource. 41 00:04:19,900 --> 00:04:28,180 So which means what if the request for the particular resource is already received before and a subsequent 42 00:04:28,180 --> 00:04:33,100 put method will replace the earlier request? 43 00:04:33,100 --> 00:04:37,050 Current representation will be replaced by the request that has been set. 44 00:04:37,630 --> 00:04:38,470 So that is put. 45 00:04:39,670 --> 00:04:47,200 Delete it, remove the current representation of the target was the requested target will be deleted. 46 00:04:47,200 --> 00:04:48,580 It will be processed and deleted. 47 00:04:49,510 --> 00:04:56,860 Press equals the received request so that the client can see any changes or additions have been done 48 00:04:57,190 --> 00:05:06,730 in the request or not and cannot convert the request connection to a transparent DCP Turnell, especially 49 00:05:06,730 --> 00:05:09,610 useful for the SSL encrypted communication. 50 00:05:10,870 --> 00:05:17,350 So these are the different methods of which we shall use the get that post method. 51 00:05:21,830 --> 00:05:36,700 So here the rule of rather the rule decorator, which defines a you all can be given an additional parameter, 52 00:05:36,710 --> 00:05:41,690 the rule function of the application object can be given an additional parameter Collette's methods 53 00:05:42,890 --> 00:05:43,580 by default. 54 00:05:43,580 --> 00:05:51,700 The method is always good, but you can change the preference by giving additional methods. 55 00:05:52,190 --> 00:06:01,670 So, for example, you see here, Eppy, not root the you are and that is defined as less function it 56 00:06:01,670 --> 00:06:06,550 can have do in front of the methods attribute. 57 00:06:06,950 --> 00:06:12,080 I'm giving a list object in which these two methods first and get are used. 58 00:06:12,650 --> 00:06:16,570 So the default is good, but then it can also be a positive method. 59 00:06:17,630 --> 00:06:19,640 So insert the definition of the function. 60 00:06:19,880 --> 00:06:28,580 You are identifying whether the request has been received as or get so how that can be done by using 61 00:06:28,580 --> 00:06:30,230 the requested documents. 62 00:06:31,490 --> 00:06:33,410 So obviously your 63 00:06:35,840 --> 00:06:43,760 import statement must have, in addition to the last class, you should also import request object. 64 00:06:44,810 --> 00:06:52,700 So the request object has a method or a function method and its value will be whichever method had been 65 00:06:52,700 --> 00:06:54,230 used by the client. 66 00:06:54,680 --> 00:06:57,950 If it is equal to post, then this block will be executed. 67 00:07:00,260 --> 00:07:00,490 Right. 68 00:07:00,620 --> 00:07:03,400 And if it is not POS, then which means what? 69 00:07:03,740 --> 00:07:05,020 You are given two options. 70 00:07:05,930 --> 00:07:10,550 So if it is equal to post, then this block, otherwise this block, that means this will be executer 71 00:07:10,550 --> 00:07:12,720 when the method is get. 72 00:07:14,060 --> 00:07:23,420 So that is how you can segregate the two activities of sending a request, either get method or method 73 00:07:23,420 --> 00:07:29,890 that business logic of processing the data, processing the function of the view function. 74 00:07:30,490 --> 00:07:40,130 This to be done when the method is both the part of it and when the matter is get so such a use of get 75 00:07:40,130 --> 00:07:41,420 and post methods will. 76 00:07:41,420 --> 00:07:47,270 Now I will show you with the help of an example in which first I will show you how the postmortem is 77 00:07:47,270 --> 00:07:54,170 used and also get the method used with the help of a demonstration example in front of you in order 78 00:07:54,170 --> 00:08:00,330 to study the different HTP methods in the flask environment. 79 00:08:00,710 --> 00:08:03,620 Let us first create an HTML form. 80 00:08:04,790 --> 00:08:11,570 In which there is a input type equal to text, text, if there was name of the full list and and then 81 00:08:11,570 --> 00:08:12,900 there is a submit button. 82 00:08:13,580 --> 00:08:21,290 So if you click on the submit button, the form data is going to be sent to this wall, which is mentioned 83 00:08:21,290 --> 00:08:23,090 in the action attribute of the form. 84 00:08:23,660 --> 00:08:27,440 And it is localhost 5000 login. 85 00:08:29,400 --> 00:08:30,540 So this is the you are. 86 00:08:32,070 --> 00:08:38,250 To which the data is going to be said and to begin with, we shall put the metal attribute of the form 87 00:08:38,250 --> 00:08:39,170 equal to post. 88 00:08:39,810 --> 00:08:43,650 So this is a simple e-mail form that we have created. 89 00:08:44,430 --> 00:08:52,830 And now this is the Python script in which this log in Eurail is defined and it is bound with the view 90 00:08:52,830 --> 00:08:54,480 function called Log-in. 91 00:08:55,840 --> 00:08:59,080 By default, this route decorator method. 92 00:09:01,010 --> 00:09:09,620 You know, accepts the data from the brother in the get method, but you can alter their behavior by 93 00:09:10,370 --> 00:09:16,820 mentioning the value to these methods parameter which can be provided to the root method. 94 00:09:17,000 --> 00:09:22,250 So metallurgic, although there are two possible values are given in the list. 95 00:09:23,480 --> 00:09:26,780 Which is the value of these methods parameter. 96 00:09:27,970 --> 00:09:33,400 So we have written a stable form which sends the letter in the post midterm. 97 00:09:34,550 --> 00:09:40,970 So if it is equal to the post, the request does not matter the value of the request or method attribute 98 00:09:40,970 --> 00:09:49,730 of this request object, then what will happen with the data associated with the barometer of the form 99 00:09:50,060 --> 00:09:54,170 will be stored in the variable called user and. 100 00:09:55,630 --> 00:10:03,340 The browser will be redirected towards the associated Eurail with the function called Wellcome, which 101 00:10:03,340 --> 00:10:04,560 is already defined here. 102 00:10:06,870 --> 00:10:10,500 We have a function called as welcome, welcome, the variable part. 103 00:10:11,570 --> 00:10:12,390 So if it. 104 00:10:13,220 --> 00:10:22,150 If the farm sells, let us anvil as the name, as a value associated with the request, not form animal, 105 00:10:22,340 --> 00:10:23,890 so user will be Annville. 106 00:10:24,170 --> 00:10:28,820 So this will come rule and associated. 107 00:10:29,880 --> 00:10:34,740 View function welcome will receive Namir, the output will be welcome. 108 00:10:36,100 --> 00:10:39,070 Whatever name that he will be providing, this will happen when. 109 00:10:40,230 --> 00:10:42,810 The data is sent in the post ometer. 110 00:10:43,760 --> 00:10:48,800 If it is not, send in the post method, otherwise it should be get because there is a second option 111 00:10:48,800 --> 00:10:49,280 is get. 112 00:10:49,640 --> 00:10:57,860 So the value associated with the enum attribute of the form can be fetched by using trick with dart. 113 00:10:58,370 --> 00:10:59,920 Energy is not get. 114 00:11:00,650 --> 00:11:01,250 So the. 115 00:11:04,020 --> 00:11:09,630 Entry in the textfield will be stored in the variable called user, and the same function will be will 116 00:11:09,630 --> 00:11:17,160 again be called in, the output of the output of both cases will be the same will come will, for instance, 117 00:11:17,610 --> 00:11:22,680 if the text box in the next e-mail form is entered with Envir. 118 00:11:23,220 --> 00:11:27,270 But in the first place, what happens when? 119 00:11:28,660 --> 00:11:30,080 The farm uses. 120 00:11:31,680 --> 00:11:36,960 Post metal attribute or get better that we have to see. 121 00:11:37,200 --> 00:11:40,530 So this is the explanation to this Log-in view function. 122 00:11:41,490 --> 00:11:47,180 Now, what we will do, we will open that e-mail form as it is, we have seen that the metrological 123 00:11:47,190 --> 00:11:52,280 the post is used, so we expect this function to be executed. 124 00:11:53,010 --> 00:11:55,020 Output will be welcome, and we'll. 125 00:11:56,320 --> 00:11:57,760 And then we will change the. 126 00:11:59,040 --> 00:12:05,200 Metal attribute of the form from push to get, and we will see that this will be executed. 127 00:12:06,090 --> 00:12:08,880 So let us now open the browser first. 128 00:12:08,880 --> 00:12:09,450 Open the. 129 00:12:10,420 --> 00:12:18,640 Esteemable form and CDG, see how the redirection takes place with the help of the you are all for function. 130 00:12:19,640 --> 00:12:24,800 So this is the former chairman that we are open inside the textbooks, let me. 131 00:12:26,710 --> 00:12:35,200 Enter the data, if I press this button, the form data will now be redirected towards the localhost 132 00:12:35,200 --> 00:12:38,800 5000 log in using the post emitter. 133 00:12:39,490 --> 00:12:40,360 So therefore. 134 00:12:41,580 --> 00:12:49,950 The associated review function to the in you are in will identify that the metal is post and therefore 135 00:12:50,640 --> 00:12:58,860 the data will be redirected towards the you are associated with a welcome name is called the Envir. 136 00:13:00,260 --> 00:13:03,020 So first, we have to start the server. 137 00:13:04,070 --> 00:13:06,050 And then press the submit button. 138 00:13:07,830 --> 00:13:10,130 So the name of the script is Start with. 139 00:13:10,240 --> 00:13:12,650 I will start the server now. 140 00:13:14,950 --> 00:13:15,610 And then. 141 00:13:19,160 --> 00:13:20,480 Press on the submit button. 142 00:13:23,260 --> 00:13:25,190 It was showing you welcome the. 143 00:13:26,350 --> 00:13:28,260 That is what is to be expected. 144 00:13:31,070 --> 00:13:34,400 Now, change the method attribute to. 145 00:13:35,590 --> 00:13:37,010 Get from post. 146 00:13:44,480 --> 00:13:47,570 And open the Australian farm again. 147 00:13:51,840 --> 00:13:54,830 So the same is form is in front of you. 148 00:13:56,380 --> 00:14:03,640 Will enter the data again and the reason we're running, so I'll press on this button. 149 00:14:08,570 --> 00:14:09,380 That is the. 150 00:14:12,830 --> 00:14:20,150 Brother is redirected towards the welcome and will you all see what is being displayed, but now this 151 00:14:20,150 --> 00:14:28,010 time the get method is in use, so that is all his people can get get methods can be used to. 152 00:14:29,090 --> 00:14:33,260 Send the data to the associated you are a.