1
00:00:00,450 --> 00:00:00,880
Beautiful.

2
00:00:01,080 --> 00:00:09,180
And with our basic headers in place now, let's deal with the request object and like I already previously

3
00:00:09,180 --> 00:00:11,190
mentioned, it's just a giant object.

4
00:00:11,210 --> 00:00:16,129
And if, of course, we can so log it, then we'll see it in a terminal.

5
00:00:16,440 --> 00:00:23,760
So I'm going to go back to my localhost 5000 and as out if this is getting quite busy so I can just

6
00:00:23,760 --> 00:00:25,680
remove some of the tabs.

7
00:00:25,950 --> 00:00:32,680
And if I just a refresh of the browser, I should see in a terminal a giant object.

8
00:00:32,960 --> 00:00:34,170
So what are we looking for?

9
00:00:34,800 --> 00:00:39,050
Well, let's go back to our slide and remember the start line.

10
00:00:39,490 --> 00:00:45,960
We had a method so that signals what the user is trying to do, either get the resource, post the resource

11
00:00:46,230 --> 00:00:49,040
or whatever, and then we have the URL.

12
00:00:49,470 --> 00:00:56,730
Now, in order to save us a little bit of time, I won't cover the methods with HTP, just deal with

13
00:00:56,730 --> 00:00:57,720
the euro.

14
00:00:58,020 --> 00:01:01,650
But we will cover, of course, methods once we hit the express.

15
00:01:01,950 --> 00:01:07,980
For now, I'm just going to assume that the only thing that the users are trying to do, they just want

16
00:01:07,980 --> 00:01:10,620
to get the resources from our server.

17
00:01:10,620 --> 00:01:12,420
So that's why we want to look for the method.

18
00:01:12,430 --> 00:01:18,840
Just keep in mind that, yes, because of those methods are available on this request object, there

19
00:01:18,840 --> 00:01:23,110
is a property by the name of I believe was just simply a method.

20
00:01:23,340 --> 00:01:30,690
So if we want to log and if I refresh ours here in a terminal, it says get.

21
00:01:31,230 --> 00:01:35,070
So the user is performing a get request.

22
00:01:35,070 --> 00:01:37,950
So the user is trying to get the resource.

23
00:01:38,220 --> 00:01:40,170
So that's one thing that we could take a look at.

24
00:01:40,320 --> 00:01:43,010
And the other one is actually the URL.

25
00:01:43,320 --> 00:01:45,090
So let me comment this one.

26
00:01:45,300 --> 00:01:48,000
And I'm looking for the you all property.

27
00:01:48,780 --> 00:01:54,540
And again, I refresh and now in the console, I should have this forward slash contact.

28
00:01:54,960 --> 00:02:01,320
So that just means that the user is trying to access the resource by the name of contact.

29
00:02:01,620 --> 00:02:05,520
And if, of course, the resources, they're awesome, we send something back.

30
00:02:05,520 --> 00:02:09,120
If not, then most likely would send back before or for now.

31
00:02:09,120 --> 00:02:14,950
If I delete that contact and if I simply go with five thousand notice, I'm going to have the fourth.

32
00:02:15,570 --> 00:02:20,220
So again, this just signals that we're getting the homepage so forward.

33
00:02:20,220 --> 00:02:26,560
Slash is going to be the homepage and then whatever other resource we would want, we would have portaledge

34
00:02:26,580 --> 00:02:27,500
and then the resource.

35
00:02:27,720 --> 00:02:34,260
Now sometimes those resources are going to be for resource name and another for slash and other resource

36
00:02:34,260 --> 00:02:35,550
name and on and on and on.

37
00:02:35,850 --> 00:02:38,090
You can really type here whatever you want.

38
00:02:38,130 --> 00:02:43,950
So again, I go with localhost about and that info and I don't know something John.

39
00:02:43,950 --> 00:02:44,280
Right.

40
00:02:44,490 --> 00:02:46,560
So I can add that here and there it is.

41
00:02:46,800 --> 00:02:52,770
Now I'm requesting this resource and if it's not there, we send back for a for if it's there, then

42
00:02:52,770 --> 00:02:55,650
of course we send back the useful info.

43
00:02:56,280 --> 00:02:57,570
So hopefully that is clear.

44
00:02:57,810 --> 00:02:58,320
Yes.

45
00:02:58,320 --> 00:03:04,050
This will just mean that it is a home page and whatever comes after the homepage, well, that's the

46
00:03:04,050 --> 00:03:06,950
resource that the user is trying to access.

47
00:03:07,290 --> 00:03:13,080
And now, of course, we can set up the if statement when I say yes, if it is a home page, please

48
00:03:13,080 --> 00:03:15,390
send back this email.

49
00:03:15,540 --> 00:03:18,660
If it is about page ten, send something else.

50
00:03:18,840 --> 00:03:24,840
And if I cannot find that resource that you're looking for, then we'll send back four or four.

51
00:03:25,170 --> 00:03:30,360
Now there's going to be a little bit of copying posting just so we can save a little bit of time.

52
00:03:30,750 --> 00:03:35,280
We're just going to go with if and actually we can set this up as a property.

53
00:03:35,280 --> 00:03:42,870
So let's go to the URL is equal to request your URL and then we'll say if you are all is equal to forward

54
00:03:42,870 --> 00:03:44,400
slash, what does that mean?

55
00:03:44,580 --> 00:03:47,100
Well, that means that it is a homepage.

56
00:03:47,400 --> 00:03:51,210
So let's grab these three lines of code and move them up.

57
00:03:51,510 --> 00:03:57,210
And now, of course, I would want to set up else if now I'll just set up one for the about page.

58
00:03:57,420 --> 00:04:02,910
So if you are all is equal to about Page, then we'll do something else.

59
00:04:03,180 --> 00:04:04,050
And if.

60
00:04:04,980 --> 00:04:06,010
None of those match.

61
00:04:06,360 --> 00:04:14,820
Well, then I'll just say else and I'll send back four for now, I will add some comments here just

62
00:04:14,820 --> 00:04:17,540
so we are clear on what is happening.

63
00:04:17,550 --> 00:04:20,220
So this is going to be about page one.

64
00:04:20,230 --> 00:04:26,610
This is going to be called home page and page, and we're going to have the or four.

65
00:04:26,610 --> 00:04:29,000
So resource not found.

66
00:04:29,490 --> 00:04:36,500
So again, in order to save us a little bit of time, I just copy and paste one and two again content

67
00:04:36,500 --> 00:04:38,120
that will be exactly the same.

68
00:04:38,130 --> 00:04:41,640
So that is going to be a demo because we'll send back the HMO.

69
00:04:42,000 --> 00:04:45,870
I'll say about and I don't know page, let's call that.

70
00:04:46,200 --> 00:04:49,170
And then the last one is going to be the four or four shown here.

71
00:04:49,180 --> 00:04:55,380
Of course, we're not going to send back two hundred, two hundred years for successful request.

72
00:04:55,860 --> 00:05:01,210
Now, of course, I want to say, hey, listen, the research that you're trying to access while it

73
00:05:01,230 --> 00:05:08,250
doesn't exist on my server, so here I go with for all four and again I go we have the same kind of

74
00:05:08,250 --> 00:05:09,570
typed text demo.

75
00:05:09,930 --> 00:05:16,220
And then let's just send back the adding one with page not found.

76
00:05:16,530 --> 00:05:17,580
So save this one.

77
00:05:18,410 --> 00:05:22,590
And now, of course, once I refresh, check it out, I get this page not found.

78
00:05:22,610 --> 00:05:22,940
Why?

79
00:05:23,180 --> 00:05:27,370
Well, because there's no resource for about info and John.

80
00:05:27,830 --> 00:05:33,400
But if I go to just about there is now, of course, I have my about page.

81
00:05:33,680 --> 00:05:39,710
And then if I go back to the home page, of course, I have had one with a homepage.

82
00:05:40,040 --> 00:05:47,240
Now we optionally if we want, we can add the status text as well.

83
00:05:48,110 --> 00:05:51,010
In order to see that, let's just go back to the known docs.

84
00:05:51,260 --> 00:05:59,240
So this is going to be the VP and of course I'm looking for a right head and we have a right hand here.

85
00:05:59,390 --> 00:06:05,980
Notice we have status code optionally we can pass in status message and then we have the headers.

86
00:06:06,230 --> 00:06:08,450
So again, let's go back to our slide.

87
00:06:08,990 --> 00:06:11,360
This is the most important one status code.

88
00:06:11,570 --> 00:06:15,410
And the status essentially is just going to be at it.

89
00:06:15,420 --> 00:06:15,920
In this case.

90
00:06:15,920 --> 00:06:24,440
We don't need to do anything because again, if we were to go back to the browser network tab, if we

91
00:06:24,440 --> 00:06:28,060
take a look at our localhost, there is first of all, this is Fortgang.

92
00:06:28,460 --> 00:06:33,020
That just means that we're going to the homepage and the status code is two hundred.

93
00:06:33,170 --> 00:06:34,920
And then we have this statistics.

94
00:06:35,270 --> 00:06:41,300
Now, again, if I navigate to a page that doesn't exist, for example, John, then of course I'm going

95
00:06:41,300 --> 00:06:43,070
to get the 404.

96
00:06:43,310 --> 00:06:48,310
So that's the start code and then the status text is not found.

97
00:06:48,710 --> 00:06:58,280
So hopefully it is clear now we have a bit more meaningful server where we have multiple resources,

98
00:06:58,530 --> 00:07:03,230
we have homepage, we have the ABOUT page and also we have the error page.

99
00:07:03,440 --> 00:07:08,990
And with this in place, of course, we can start working on a more complex set up.

