Now this is a very basic Express.js application, arguably not a very beautiful one either but it shows
us the basic idea behind Express.js and Node.js
and it gives you an idea of how you work with that and that it is just Javascript with new packages
you can use which you can't use in the browser
and with some new built-in modules like this filesystem module used earlier but in the end it's just
Javascript, just running in a different environment and therefore with a different purpose.
Now here we're building a traditional web page I'd say, where we render all the HTML pages on the
server and we return them and there is nothing wrong with that.
Again I can only point that my complete Node.js guide if you want to learn all about Node.js because
well that's over 30-hour course,
there are a lot of topics to cover when it comes to Node.js,
so here we can of course only scratch the surface.
Nonetheless I want to dive into one other way of web application, of backend, of server side
you could build with Node.js.
Here we got a web application that renders HTML files on the server and sends them back to the client.
Now if you remember our practice app from earlier, what we did there for example is we got the location
or the address or the coordinates for certain places on a map from Google's servers,
we send the request to Google's servers. Now clearly what these servers sent us back was not HTML
data, it was JSON data which we parsed with this JSON method if you remembered and indeed when sending
requests from client side Javascript to some server, you typically exchange JSON data because on the
client side Javascript, you might then have logic that edits the existing HTML page you're on but you
don't want to replace it entirely with some HTML code sent back by the server, you don't want to reload
the entire page, you might want to tweak some parts of the page to give the user that highly reactive
feeling. So therefore this is a server which does not return HTML as our server currently does here
but instead it returns JSON data and we can of course build such a server too. Why don't we do that and
connect it here with this little practice application by ensuring that when we create a place there,
so when we create this share place link, we don't encode all that information here into the link
but instead we generate an ID for that place on the server side, store that in a database on the server
side and send that link back to the client side code,
so to this code and then when a user visits this link which includes that ID thereafter and therefore
the user ends up on this other index.html file and and so up in the my-place.js file, we parse that ID
from the URL and again reach out to this backend server here to get the data, the address and the coordinates
for that ID from our database and then send this data back via JSON or as JSON to this client side
application so that there we can then render this. Why don't we do it like this,
this would be a nice practice and that's therefore exactly what we'll do next
so that we also explore this other way of or this other kind of backend service we could build, also often
known as an API or specifically, a REST API, an interface we can talk to from any client we want as long
as we send the correct data to the correct URL.