WEBVTT

00:05.200 --> 00:07.400
Pay everyone welcome back.

00:07.400 --> 00:14.390
So in the last video we talked about Jason what Jason is in how we can use it as a format to send data

00:14.420 --> 00:16.500
from one server to the other.

00:16.520 --> 00:22.040
So in this video we're going to go back into eight to talk about HTB are we going to be talking about

00:22.040 --> 00:27.430
in much more detail so that we understand what we're supposed to do when we're developing a server.

00:27.860 --> 00:32.310
Ok so let's get started again with the same example that we always do.

00:32.450 --> 00:40.370
So let's say that you have your browser over here that's your browser and then on here we have Google

00:40.370 --> 00:49.950
servers so called servers and on it is how the the Web site google.com is hosted.

00:50.450 --> 00:56.580
OK so let's say you write google.com in your browser and again your browser goes to your ISP.

00:56.600 --> 01:02.730
You know does a DNS look up all that stuff and finally gets the IP for your Google server.

01:02.860 --> 01:03.950
And that's what we care about.

01:03.950 --> 01:06.620
We don't really care about the process in here.

01:06.770 --> 01:14.820
Now once we have the IP then your browser wants to initiate a request to your Google to Google the company.

01:15.200 --> 01:18.580
So our request should have a specific format.

01:18.720 --> 01:19.260
OK.

01:19.520 --> 01:23.240
The last time we were just saying well required we just send the request direct.

01:23.240 --> 01:28.040
So in this video we're going to be explaining how the request and the response should look like.

01:28.280 --> 01:37.100
So whether the request request can be should star in the beginning to identify what type of request

01:37.340 --> 01:37.800
this is.

01:37.910 --> 01:39.420
What message are you using.

01:39.680 --> 01:45.500
And there are so many different methods that you can use during a request for this video and really

01:45.500 --> 01:49.210
for most of the development we only focus on two of them.

01:49.390 --> 01:54.700
So we have to get to request and we have a POST request.

01:54.830 --> 01:58.250
Now you might you might be wondering OK what's it got what's pose.

01:58.250 --> 02:04.910
And actually we've been using so far all along throughout the videos we've actually been using get now

02:04.940 --> 02:05.260
what.

02:05.310 --> 02:10.960
Get means is that it simply requests from the server to get right.

02:10.970 --> 02:16.380
And the name suggests to get a specific resource from their server.

02:16.820 --> 02:22.880
And what what what kind of a resource is identified by what's after.

02:23.060 --> 02:36.470
So if I say get from Google that can and then right after it slash index ASTM then I'm requesting from

02:36.470 --> 02:38.840
Google dot com to give me their resource.

02:38.870 --> 02:43.450
Each DMA I'm requesting to get that resource from there.

02:43.880 --> 02:51.470
So in other words again it is just simply asking the server Hey sir I need some resource whether it's

02:51.670 --> 03:01.070
page whether it's you know some kind of resource and that and this and this place with that name then

03:01.070 --> 03:03.020
I simply use get to get it.

03:03.020 --> 03:05.440
Now we've been using this so far we always have.

03:05.460 --> 03:14.180
If you feel actually if we actually go back to our coding example here and at the root by Slash by and

03:14.180 --> 03:19.060
then if we actually go to the answer here we'll see here that one.

03:19.100 --> 03:21.500
So let's let's run flask here.

03:21.890 --> 03:22.540
Okay.

03:22.820 --> 03:30.770
And then if we go to here 2 2 to localhost slash by the way click enter and then we get the response

03:30.770 --> 03:31.070
back.

03:31.070 --> 03:39.870
You'll notice here that it says Get So we got gotten a request and slash by.

03:40.190 --> 03:46.110
So we get request and at the end point slash right.

03:46.490 --> 03:49.480
And it's using the protocol HTP.

03:49.610 --> 03:57.020
So that means that we're so far away when our browser really is clicking enter here what it is doing

03:57.140 --> 04:06.070
is setting up a get request to our server local server telling and hey I want whatever is that slash

04:06.310 --> 04:07.130
bye.

04:07.760 --> 04:11.040
And that's simply this is basically what a request is.

04:11.150 --> 04:17.190
We are requesting resource from from the server and the server responds to us whether it's an indexed

04:17.360 --> 04:23.270
HMO page whether it's a sign whether it's you know X amount which we're not going to be talking about

04:23.700 --> 04:27.750
some kind of response and then we get it back and that's it.

04:27.800 --> 04:30.540
That's our communication server.

04:30.780 --> 04:37.110
Now the second most famous type of request is actually the post request.

04:37.130 --> 04:39.750
So what is the request what what is it.

04:39.770 --> 04:45.470
It's basically that we're requesting from the server to request to access something that we're sending

04:45.470 --> 04:46.450
to it.

04:46.490 --> 04:55.190
So we're saying hey Google or com or hey you know slash my please accept this Jason or this you know

04:55.290 --> 04:56.740
you SML or whatever.

04:56.900 --> 05:03.110
Please accept whatever I'm going to be sending you and give me a response.

05:03.200 --> 05:09.830
So it's saying hey hostess something us so so post comes from you know when you post someone in email

05:09.850 --> 05:13.270
read your postings you're sending something to him.

05:13.360 --> 05:17.220
So you're posting something to the server whatever that something is.

05:17.240 --> 05:24.040
But we're going to see how is Jason actually as you might have guessed so we're saying hey server I'm

05:24.040 --> 05:28.530
sending you some Jaison at this point please accept it.

05:28.840 --> 05:37.270
And then the server is up to the server to either accept or deny that that that that coast right because

05:37.350 --> 05:40.990
someone someone might send me some you know malware right.

05:40.990 --> 05:43.000
I don't want to accept malware.

05:43.150 --> 05:47.750
So we're going to see how we can you know authentically and against the stuff in later videos.

05:47.890 --> 05:50.200
But for now let's assume all the users are nice.

05:50.200 --> 05:50.420
Right.

05:50.420 --> 05:55.460
No is going to try to hack our Web site so people are going to be sending us some Jason.

05:55.840 --> 06:00.430
And then regarding this Jason and then we're going to say OK what are we going to do.

06:00.760 --> 06:08.590
So these are the two types of requests whenever whenever our browser wants to make a request to another

06:08.590 --> 06:17.560
server or two or really whenever any server wants to make a request to another server using HTP then

06:17.560 --> 06:24.400
it has to prepare our request and this request can be either get post or some some you know there is

06:24.480 --> 06:31.360
you know there is also I think hand and there's all sort of protocols but really these two are the most

06:31.360 --> 06:33.040
famous ones which.

06:33.070 --> 06:36.240
And we'll be spending a lot of time on those.

06:36.400 --> 06:44.680
So get get get really quick recap quickly get give me some resources at this location post Hey I'm sending

06:44.680 --> 06:51.580
you some information and I want a response so you can think of a post as you know I'm sending information

06:51.610 --> 06:55.830
plus I'm getting you know I'm expecting something in return.

06:56.490 --> 06:57.030
OK.

06:57.070 --> 07:06.430
So once Google receives this request and for example slash slides and say OK so the user wants and get

07:07.330 --> 07:09.370
ad slashed by.

07:10.000 --> 07:19.690
So I'm going to take this request and prepare what is called response to Google or even our website

07:19.780 --> 07:23.160
or our API needs to send a response right.

07:23.200 --> 07:30.880
Our response is basically saying a user sent me your request so I told him to send him back a response

07:30.880 --> 07:31.770
right.

07:31.960 --> 07:33.310
I sent someone a request.

07:33.460 --> 07:35.280
He gives me no response.

07:35.320 --> 07:37.560
So what is the structure of the response.

07:37.750 --> 07:42.420
Well the response is first made a status line.

07:42.460 --> 07:49.290
So what is the status line as status line contains one number which is status code.

07:49.690 --> 07:54.270
So status quo basically says what happened to the overall request.

07:54.460 --> 07:59.780
So for example the most common status code you would see is 200.

08:00.040 --> 08:01.050
OK.

08:01.360 --> 08:06.010
Which basically means that 200 was this request was a success.

08:06.250 --> 08:13.320
So we succeeded your request was successfully handled and this response basically means that hey I'm

08:13.330 --> 08:18.820
returning the responses that you're expecting here because your request was successful.

08:18.820 --> 08:26.320
Another one which we're always you know you always hear jokes about is 404 not found which basically

08:26.320 --> 08:32.890
means you know it can mean a lot of things but maybe even slash for example are slashed by maybe this

08:32.940 --> 08:35.570
end point is not even at the server.

08:35.620 --> 08:40.600
So it sends me a response back that Google tells me hey you know I don't have anything called slash

08:40.600 --> 08:41.010
by.

08:41.020 --> 08:50.950
Right so if I if I go back to my At-Home here and if I comment you know this all these lines of code

08:51.640 --> 08:55.460
from here to here and then I save.

08:55.660 --> 09:05.710
And then again I paused this and rerun flask and then if I try to access slash by then what I'll get

09:05.890 --> 09:08.190
is not found 404.

09:08.320 --> 09:09.100
Right.

09:09.100 --> 09:12.020
So here you will see get slashed by.

09:12.040 --> 09:14.190
But then it returns 404.

09:14.410 --> 09:16.020
That that means it's a failure.

09:16.060 --> 09:17.930
I haven't found this resource.

09:17.980 --> 09:20.300
I don't have a slash by resource here.

09:20.390 --> 09:21.040
Right.

09:21.370 --> 09:22.130
OK.

09:22.360 --> 09:23.560
Let's continue.

09:24.100 --> 09:25.950
So we get a stainless go.

09:25.960 --> 09:28.450
There are so many types of this goes right.

09:28.450 --> 09:32.390
But these two are the most famous ones we're going to see so many other ones.

09:32.470 --> 09:37.740
Others you know invalid argument invalid blah blah blah we're going to see a lot of them.

09:37.750 --> 09:44.850
So we have to return for a sustained unscrewed and then after the state is good we have to return a

09:44.860 --> 09:49.960
message body so a message body is what the user is expecting.

09:49.960 --> 09:58.430
So in our case it's going to be Jason so we're saying oh field one you know blah blah.

09:58.570 --> 10:00.400
Right.

10:00.850 --> 10:08.000
And so were so really turning some object responds body using a Jaser.

10:08.020 --> 10:14.040
So to recap really quickly we're preparing our request right.

10:14.230 --> 10:16.960
And you might be wondering for a post request right.

10:16.960 --> 10:21.360
I might have admitted this when I'm sending a post request.

10:21.360 --> 10:30.550
There is also this message body image right so I can also put message body in their quest and then I

10:30.550 --> 10:38.770
can send you know I Jason this Jason means hey this is what I'm posting to the server.

10:38.890 --> 10:45.550
Right so this server should except this post post message and then it's going to return me a status

10:45.550 --> 10:46.170
code.

10:46.330 --> 10:54.190
For example 200 and then the message body is going to be well the adjacent that I'm expecting is.

10:54.190 --> 10:55.780
So hopefully this makes sense.

10:55.780 --> 11:02.530
So to recap really quickly we have a request and then we have our response.

11:02.530 --> 11:12.800
This one could be a get slash post slash lead slash head and lots and lots of methods.

11:13.390 --> 11:17.560
And then the response should have instant Stinnes good.

11:18.550 --> 11:22.740
And then here we would have message body.

11:24.280 --> 11:26.190
In the case of the post.

11:26.410 --> 11:26.820
Right.

11:26.860 --> 11:34.110
So in the case of post we have a message body and then in the response we also have a message Varney's

11:34.110 --> 11:35.130
on this right.

11:35.240 --> 11:42.580
M-B and then it's also the sun where you can send information back to the user and that's about it.

11:42.580 --> 11:43.570
So in the next video.

11:43.600 --> 11:52.240
So for all we're doing really if we go back here oh what we've been doing really is we're simply using

11:53.910 --> 11:55.240
GET requests.

11:55.300 --> 12:00.600
If you see like Slash or slash hire there all these are we simply having an end point.

12:00.610 --> 12:04.520
We're getting an end point and we're getting a response a very basic response.

12:04.630 --> 12:05.180
Right.

12:05.440 --> 12:12.250
So in the next video we're going to see how we can as a user send send the server or something.

12:12.260 --> 12:12.680
Right.

12:12.790 --> 12:19.780
So at me as a user I want to send the server something for example to numbers and then I want to ask

12:19.780 --> 12:24.850
the server to add these two numbers and send me your response back.

12:25.390 --> 12:31.870
So instead of doing this stuff here we're going to say hey server these two numbers add them together

12:32.140 --> 12:34.270
and send me your response back.

12:34.810 --> 12:39.690
So we'll see how we can do this using a post Massad in the next.

12:40.070 --> 12:43.240
So yeah until the next video had become.
