1
00:00:02,160 --> 00:00:08,700
Now this is a very basic Express.js application, arguably not a very beautiful one either but it shows

2
00:00:08,700 --> 00:00:12,710
us the basic idea behind Express.js and Node.js

3
00:00:12,720 --> 00:00:18,600
and it gives you an idea of how you work with that and that it is just Javascript with new packages

4
00:00:18,600 --> 00:00:21,680
you can use which you can't use in the browser

5
00:00:21,840 --> 00:00:28,620
and with some new built-in modules like this filesystem module used earlier but in the end it's just

6
00:00:28,620 --> 00:00:33,480
Javascript, just running in a different environment and therefore with a different purpose.

7
00:00:33,480 --> 00:00:39,600
Now here we're building a traditional web page I'd say, where we render all the HTML pages on the

8
00:00:39,600 --> 00:00:42,940
server and we return them and there is nothing wrong with that.

9
00:00:42,960 --> 00:00:47,880
Again I can only point that my complete Node.js guide if you want to learn all about Node.js because

10
00:00:48,090 --> 00:00:50,890
well that's over 30-hour course,

11
00:00:50,910 --> 00:00:54,020
there are a lot of topics to cover when it comes to Node.js,

12
00:00:54,030 --> 00:00:56,640
so here we can of course only scratch the surface.

13
00:00:56,670 --> 00:01:02,820
Nonetheless I want to dive into one other way of web application, of backend, of server side

14
00:01:02,820 --> 00:01:05,310
you could build with Node.js.

15
00:01:05,310 --> 00:01:11,760
Here we got a web application that renders HTML files on the server and sends them back to the client.

16
00:01:11,760 --> 00:01:18,450
Now if you remember our practice app from earlier, what we did there for example is we got the location

17
00:01:18,510 --> 00:01:23,550
or the address or the coordinates for certain places on a map from Google's servers,

18
00:01:23,550 --> 00:01:29,940
we send the request to Google's servers. Now clearly what these servers sent us back was not HTML

19
00:01:29,940 --> 00:01:36,510
data, it was JSON data which we parsed with this JSON method if you remembered and indeed when sending

20
00:01:36,510 --> 00:01:43,680
requests from client side Javascript to some server, you typically exchange JSON data because on the

21
00:01:43,680 --> 00:01:49,890
client side Javascript, you might then have logic that edits the existing HTML page you're on but you

22
00:01:49,890 --> 00:01:56,790
don't want to replace it entirely with some HTML code sent back by the server, you don't want to reload

23
00:01:56,820 --> 00:02:02,430
the entire page, you might want to tweak some parts of the page to give the user that highly reactive

24
00:02:02,490 --> 00:02:09,140
feeling. So therefore this is a server which does not return HTML as our server currently does here

25
00:02:09,560 --> 00:02:16,970
but instead it returns JSON data and we can of course build such a server too. Why don't we do that and

26
00:02:16,960 --> 00:02:23,610
connect it here with this little practice application by ensuring that when we create a place there,

27
00:02:23,690 --> 00:02:30,880
so when we create this share place link, we don't encode all that information here into the link

28
00:02:31,340 --> 00:02:39,710
but instead we generate an ID for that place on the server side, store that in a database on the server

29
00:02:39,710 --> 00:02:43,670
side and send that link back to the client side code,

30
00:02:43,700 --> 00:02:50,710
so to this code and then when a user visits this link which includes that ID thereafter and therefore

31
00:02:50,780 --> 00:02:58,940
the user ends up on this other index.html file and and so up in the my-place.js file, we parse that ID

32
00:02:58,970 --> 00:03:06,350
from the URL and again reach out to this backend server here to get the data, the address and the coordinates

33
00:03:06,500 --> 00:03:15,770
for that ID from our database and then send this data back via JSON or as JSON to this client side

34
00:03:15,770 --> 00:03:20,200
application so that there we can then render this. Why don't we do it like this,

35
00:03:20,190 --> 00:03:23,990
this would be a nice practice and that's therefore exactly what we'll do next

36
00:03:23,990 --> 00:03:30,280
so that we also explore this other way of or this other kind of backend service we could build, also often

37
00:03:30,290 --> 00:03:39,170
known as an API or specifically, a REST API, an interface we can talk to from any client we want as long

38
00:03:39,170 --> 00:03:42,140
as we send the correct data to the correct URL.
