1 00:00:00,510 --> 00:00:06,510 In this part, we are going to create a survey that they send a request from the browser and decide 2 00:00:06,510 --> 00:00:09,180 what response to send to the process. 3 00:00:09,330 --> 00:00:12,410 So first we did all the unnecessary things. 4 00:00:12,900 --> 00:00:14,610 So we did it, these files. 5 00:00:19,390 --> 00:00:21,130 And that means that we create. 6 00:00:22,100 --> 00:00:29,960 And instead, we create a new file called SSAFA, and this is the name you wanted, but we just want 7 00:00:29,960 --> 00:00:32,140 to create a server. 8 00:00:32,550 --> 00:00:32,960 Yes. 9 00:00:33,940 --> 00:00:45,460 And for us, we required to call Mojo's code, so we create a constant HTP equal to require HTP and 10 00:00:45,460 --> 00:00:50,210 then to create a server we can use HTP not. 11 00:00:52,180 --> 00:01:00,040 Great surfer method, and we can also store these into a surfer, Constance. 12 00:01:05,870 --> 00:01:08,030 And they say combat functions. 13 00:01:11,670 --> 00:01:18,040 And this one shouldn't be a one every time a request come to the server and this function takes a week 14 00:01:18,330 --> 00:01:22,110 object and also a response object that they perimeter's. 15 00:01:24,120 --> 00:01:31,430 The weakest object contains things such as we do our own, but in this exampled, we ignore it and just 16 00:01:31,450 --> 00:01:32,070 returns. 17 00:01:33,510 --> 00:01:34,890 A crash is made. 18 00:01:38,320 --> 00:01:43,480 The response object is to send a response to the user in the browser. 19 00:01:44,460 --> 00:01:51,930 To actively listening for the request being sent to the surface, to actively listen for the request 20 00:01:52,200 --> 00:01:55,600 being sent to the surface, we need to invoked a listening method. 21 00:01:55,620 --> 00:02:07,320 So we have to read it or listen, and then we have to pass the arguments like port hostname and we have 22 00:02:07,320 --> 00:02:09,510 and create these reasonable. 23 00:02:10,520 --> 00:02:22,370 So we have to create a constant port is equal to 3000 and constant hostname is equal to localhost and 24 00:02:22,400 --> 00:02:32,960 I we have a callback function and every console a lot listening on board. 25 00:02:34,830 --> 00:02:44,030 And we use Temperley tomorrow to pass the lumber here so we can run the program by piping note server. 26 00:02:45,860 --> 00:02:52,640 And we cannot find a module's you cannot find a motive, and because databased problems occurred that 27 00:02:52,640 --> 00:03:01,580 I created foder here, so I have to move this file to the voter and runs the server again. 28 00:03:04,520 --> 00:03:07,340 And you can see the process is ongoing. 29 00:03:07,340 --> 00:03:12,610 And this is because the server is running in the background and listening for the request. 30 00:03:12,920 --> 00:03:16,160 So to cancel this, we can press control, see? 31 00:03:17,410 --> 00:03:25,810 To cancel the server and actually we can also delete this one, because for localhost we can skip this, 32 00:03:25,960 --> 00:03:31,970 but for other cases you have to add the hostname so we can run the server again. 33 00:03:33,930 --> 00:03:40,560 And if we go to the browser and type localhost free thousands and the browser use hand and waiting for 34 00:03:40,560 --> 00:03:46,710 the server response, but we do not end, but we do not get any response yet. 35 00:03:46,840 --> 00:03:53,700 So when you go back to the surf and you can see a message, a request is made is logged it to the console.