Pay everyone welcome back.
So in the last video we talked about Jason what Jason is in how we can use it as a format to send data
from one server to the other.
So in this video we're going to go back into eight to talk about HTB are we going to be talking about
in much more detail so that we understand what we're supposed to do when we're developing a server.
Ok so let's get started again with the same example that we always do.
So let's say that you have your browser over here that's your browser and then on here we have Google
servers so called servers and on it is how the the Web site google.com is hosted.
OK so let's say you write google.com in your browser and again your browser goes to your ISP.
You know does a DNS look up all that stuff and finally gets the IP for your Google server.
And that's what we care about.
We don't really care about the process in here.
Now once we have the IP then your browser wants to initiate a request to your Google to Google the company.
So our request should have a specific format.
OK.
The last time we were just saying well required we just send the request direct.
So in this video we're going to be explaining how the request and the response should look like.
So whether the request request can be should star in the beginning to identify what type of request
this is.
What message are you using.
And there are so many different methods that you can use during a request for this video and really
for most of the development we only focus on two of them.
So we have to get to request and we have a POST request.
Now you might you might be wondering OK what's it got what's pose.
And actually we've been using so far all along throughout the videos we've actually been using get now
what.
Get means is that it simply requests from the server to get right.
And the name suggests to get a specific resource from their server.
And what what what kind of a resource is identified by what's after.
So if I say get from Google that can and then right after it slash index ASTM then I'm requesting from
Google dot com to give me their resource.
Each DMA I'm requesting to get that resource from there.
So in other words again it is just simply asking the server Hey sir I need some resource whether it's
page whether it's you know some kind of resource and that and this and this place with that name then
I simply use get to get it.
Now we've been using this so far we always have.
If you feel actually if we actually go back to our coding example here and at the root by Slash by and
then if we actually go to the answer here we'll see here that one.
So let's let's run flask here.
Okay.
And then if we go to here 2 2 to localhost slash by the way click enter and then we get the response
back.
You'll notice here that it says Get So we got gotten a request and slash by.
So we get request and at the end point slash right.
And it's using the protocol HTP.
So that means that we're so far away when our browser really is clicking enter here what it is doing
is setting up a get request to our server local server telling and hey I want whatever is that slash
bye.
And that's simply this is basically what a request is.
We are requesting resource from from the server and the server responds to us whether it's an indexed
HMO page whether it's a sign whether it's you know X amount which we're not going to be talking about
some kind of response and then we get it back and that's it.
That's our communication server.
Now the second most famous type of request is actually the post request.
So what is the request what what is it.
It's basically that we're requesting from the server to request to access something that we're sending
to it.
So we're saying hey Google or com or hey you know slash my please accept this Jason or this you know
you SML or whatever.
Please accept whatever I'm going to be sending you and give me a response.
So it's saying hey hostess something us so so post comes from you know when you post someone in email
read your postings you're sending something to him.
So you're posting something to the server whatever that something is.
But we're going to see how is Jason actually as you might have guessed so we're saying hey server I'm
sending you some Jaison at this point please accept it.
And then the server is up to the server to either accept or deny that that that that coast right because
someone someone might send me some you know malware right.
I don't want to accept malware.
So we're going to see how we can you know authentically and against the stuff in later videos.
But for now let's assume all the users are nice.
Right.
No is going to try to hack our Web site so people are going to be sending us some Jason.
And then regarding this Jason and then we're going to say OK what are we going to do.
So these are the two types of requests whenever whenever our browser wants to make a request to another
server or two or really whenever any server wants to make a request to another server using HTP then
it has to prepare our request and this request can be either get post or some some you know there is
you know there is also I think hand and there's all sort of protocols but really these two are the most
famous ones which.
And we'll be spending a lot of time on those.
So get get get really quick recap quickly get give me some resources at this location post Hey I'm sending
you some information and I want a response so you can think of a post as you know I'm sending information
plus I'm getting you know I'm expecting something in return.
OK.
So once Google receives this request and for example slash slides and say OK so the user wants and get
ad slashed by.
So I'm going to take this request and prepare what is called response to Google or even our website
or our API needs to send a response right.
Our response is basically saying a user sent me your request so I told him to send him back a response
right.
I sent someone a request.
He gives me no response.
So what is the structure of the response.
Well the response is first made a status line.
So what is the status line as status line contains one number which is status code.
So status quo basically says what happened to the overall request.
So for example the most common status code you would see is 200.
OK.
Which basically means that 200 was this request was a success.
So we succeeded your request was successfully handled and this response basically means that hey I'm
returning the responses that you're expecting here because your request was successful.
Another one which we're always you know you always hear jokes about is 404 not found which basically
means you know it can mean a lot of things but maybe even slash for example are slashed by maybe this
end point is not even at the server.
So it sends me a response back that Google tells me hey you know I don't have anything called slash
by.
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
from here to here and then I save.
And then again I paused this and rerun flask and then if I try to access slash by then what I'll get
is not found 404.
Right.
So here you will see get slashed by.
But then it returns 404.
That that means it's a failure.
I haven't found this resource.
I don't have a slash by resource here.
Right.
OK.
Let's continue.
So we get a stainless go.
There are so many types of this goes right.
But these two are the most famous ones we're going to see so many other ones.
Others you know invalid argument invalid blah blah blah we're going to see a lot of them.
So we have to return for a sustained unscrewed and then after the state is good we have to return a
message body so a message body is what the user is expecting.
So in our case it's going to be Jason so we're saying oh field one you know blah blah.
Right.
And so were so really turning some object responds body using a Jaser.
So to recap really quickly we're preparing our request right.
And you might be wondering for a post request right.
I might have admitted this when I'm sending a post request.
There is also this message body image right so I can also put message body in their quest and then I
can send you know I Jason this Jason means hey this is what I'm posting to the server.
Right so this server should except this post post message and then it's going to return me a status
code.
For example 200 and then the message body is going to be well the adjacent that I'm expecting is.
So hopefully this makes sense.
So to recap really quickly we have a request and then we have our response.
This one could be a get slash post slash lead slash head and lots and lots of methods.
And then the response should have instant Stinnes good.
And then here we would have message body.
In the case of the post.
Right.
So in the case of post we have a message body and then in the response we also have a message Varney's
on this right.
M-B and then it's also the sun where you can send information back to the user and that's about it.
So in the next video.
So for all we're doing really if we go back here oh what we've been doing really is we're simply using
GET requests.
If you see like Slash or slash hire there all these are we simply having an end point.
We're getting an end point and we're getting a response a very basic response.
Right.
So in the next video we're going to see how we can as a user send send the server or something.
Right.
So at me as a user I want to send the server something for example to numbers and then I want to ask
the server to add these two numbers and send me your response back.
So instead of doing this stuff here we're going to say hey server these two numbers add them together
and send me your response back.
So we'll see how we can do this using a post Massad in the next.
So yeah until the next video had become.