1
00:00:04,750 --> 00:00:08,440
Let's improve our server creation a little bit.

2
00:00:09,070 --> 00:00:19,060
Let's say that if a user visit our URL, for example, look our hosts semicolon 9004 slice login.

3
00:00:19,210 --> 00:00:23,050
We want to render or display a login page.

4
00:00:23,080 --> 00:00:31,540
Or let's say if the user tried to enter or visit register page, we want to render a register page.

5
00:00:31,570 --> 00:00:40,210
It simply means that we are going to respond to you our error and retain a response based on that URL.

6
00:00:40,300 --> 00:00:44,590
But for the meantime, we are just going to display some static text.

7
00:00:44,590 --> 00:00:50,200
So we are going to create a template or a HTML template for this.

8
00:00:50,350 --> 00:00:59,260
So in this video, we are going to create to a HTML that is log in page and then the register page.

9
00:00:59,530 --> 00:01:01,260
We can do it manually.

10
00:01:01,270 --> 00:01:03,970
That is right clicking and the name of the file.

11
00:01:04,000 --> 00:01:07,360
Let's say log in, dot html.

12
00:01:07,840 --> 00:01:13,550
Or better still, we can use the Node.js technique to get that one done.

13
00:01:13,570 --> 00:01:18,160
So let me show you how we're going to use Node.js to create a HTML templates.

14
00:01:18,430 --> 00:01:22,750
Well, we have done that one before using the FS module.

15
00:01:22,840 --> 00:01:27,640
So let's see how we are going to use the FS module to create a HTML template.

16
00:01:27,670 --> 00:01:35,860
So first, let's require the FS module equal to the required and then the name of the module which is

17
00:01:35,860 --> 00:01:36,640
FS.

18
00:01:37,030 --> 00:01:42,340
Now down here, let's remove this one and let's say create.

19
00:01:44,360 --> 00:01:47,720
Logging a HTML file.

20
00:01:47,750 --> 00:01:49,730
So here is a very simple one.

21
00:01:49,910 --> 00:01:55,660
So I'm going to use F s start right file, remember?

22
00:01:55,790 --> 00:02:00,650
So the first agreement is we pass in the file that we want to create.

23
00:02:00,830 --> 00:02:04,610
So we're going to create log in towards HTML.

24
00:02:05,210 --> 00:02:12,260
The second element is going to be the text or the content that we want to write.

25
00:02:12,620 --> 00:02:17,420
But for our purpose, we are going to create a simple HTML syntax.

26
00:02:17,630 --> 00:02:25,700
So let's use bug for this because I want expand it and write a few lines of HTML so I can bring this

27
00:02:25,700 --> 00:02:27,530
one down here as that.

28
00:02:27,530 --> 00:02:33,050
Now I have my back so here I can write any valid HTML code here.

29
00:02:33,260 --> 00:02:34,460
So here we go.

30
00:02:34,490 --> 00:02:39,290
I need a dev to drop that then the div.

31
00:02:39,320 --> 00:02:43,460
Let's close it down here n as that very simple one.

32
00:02:43,880 --> 00:02:52,520
The next one is let's create h one and says that this is logging.

33
00:02:53,240 --> 00:02:57,890
Page and let's close the tag here.

34
00:02:58,130 --> 00:03:04,460
And after that, let's add some P tag here and let's say please.

35
00:03:05,560 --> 00:03:06,670
Provide.

36
00:03:09,020 --> 00:03:12,440
Your wallet login.

37
00:03:13,340 --> 00:03:14,160
Credentials.

38
00:03:14,180 --> 00:03:15,950
Just some simple text here.

39
00:03:16,190 --> 00:03:17,780
Not real logging.

40
00:03:18,170 --> 00:03:18,650
All right.

41
00:03:18,650 --> 00:03:21,380
You can write any HTML code here.

42
00:03:21,590 --> 00:03:25,970
Now, after that, we need to pass in a second argument.

43
00:03:26,000 --> 00:03:27,920
That's going to be the callback function.

44
00:03:27,920 --> 00:03:32,620
So comma here, let's use a function and pass in the error.

45
00:03:32,630 --> 00:03:35,090
And here we go.

46
00:03:35,660 --> 00:03:40,610
So inside the callback, let's check if there is going to be an error.

47
00:03:40,730 --> 00:03:45,260
Then you go ahead and then display the error.

48
00:03:45,680 --> 00:03:48,530
Otherwise, you say that.

49
00:03:49,660 --> 00:03:54,970
Console.log attacks say that file has been.

50
00:03:56,870 --> 00:03:57,870
Created.

51
00:03:57,890 --> 00:03:58,670
Now.

52
00:03:58,700 --> 00:03:59,750
Moment of truth.

53
00:03:59,750 --> 00:04:01,040
Let's save it now.

54
00:04:01,040 --> 00:04:02,570
Let's run the file.

55
00:04:02,600 --> 00:04:05,440
That is, restart our file, our server.

56
00:04:05,450 --> 00:04:10,850
So control C to shut down, clear the console and now let's check it out.

57
00:04:10,850 --> 00:04:16,519
As soon as we run the file, you're going to see that you are going to have log in a HTML file here.

58
00:04:16,790 --> 00:04:20,269
So now moment of truth, let's run the application.

59
00:04:20,269 --> 00:04:23,630
Nine can see that file has been created.

60
00:04:23,630 --> 00:04:24,470
Let's check it out.

61
00:04:24,470 --> 00:04:33,470
Indeed, we have a HTML here and I can open this one and definitely I'm going to see the HTML here,

62
00:04:33,830 --> 00:04:37,490
but we are going to use Node.js to display this.

63
00:04:37,490 --> 00:04:39,200
So let's close this one.

64
00:04:39,650 --> 00:04:42,080
Now we are done with the first one.

65
00:04:42,080 --> 00:04:44,120
We are going to create two templates.

66
00:04:44,150 --> 00:04:47,120
The first one is a log in, the next are going to be the register.

67
00:04:47,120 --> 00:04:50,180
So let's also copy this one.

68
00:04:51,110 --> 00:04:55,310
And let's comment this one.

69
00:04:56,150 --> 00:04:57,710
For future references.

70
00:04:58,100 --> 00:05:02,690
It's here and let's change this one to register.

71
00:05:02,690 --> 00:05:06,620
And let's change this one to this is register.

72
00:05:08,880 --> 00:05:09,720
Page.

73
00:05:09,720 --> 00:05:14,820
And here you can change this one unless it provides your details.

74
00:05:16,100 --> 00:05:16,700
As that.

75
00:05:16,700 --> 00:05:21,800
So now moment of truth, let's also shut down a server and run again.

76
00:05:21,800 --> 00:05:26,300
And indeed, I'm going to have two templates here as that.

77
00:05:26,300 --> 00:05:28,580
So now we are done with the file creation.

78
00:05:28,580 --> 00:05:34,890
So let's call this one and let's collapse this one and let's have let's comment this one or so.

79
00:05:35,420 --> 00:05:35,840
All right.

80
00:05:35,840 --> 00:05:37,670
So let's collapse it as that.

81
00:05:37,670 --> 00:05:38,120
All right.

82
00:05:38,120 --> 00:05:40,490
Now we are done with the file creation.

83
00:05:40,490 --> 00:05:44,540
The next step is how can we respond to a root?

84
00:05:44,540 --> 00:05:53,650
Let's say that if a user visit for a slash, for example, register, we want to render the register

85
00:05:53,660 --> 00:05:55,130
a HTML templates.

86
00:05:55,130 --> 00:05:58,520
So let's see how we're going to do that one in the next video.

