we are simply responding by rendering the exact page as before (whats the point in that)
There is no point, but its looks like a tutorial designed to demonstrate basic principles and not be a practical and useful thing.
What is confusing me about this code is that it is saying we are getting a req from the thanks.html which has not been made yet.
The first argument of app.post
or app.get
is the path that should appear in the URL that the browser is requesting from the server.
This is not a file name.
The response is determined by the code in the function that is the second argument. That’s not a file unless the code explicitly reads a file.
res.render("thanks", {data});
tells Express to use a template called thanks
(and you should have previously configured a template engine) which gets passes the data from the request.
If you haven’t make a thanks
template, then requests for /thanks.html
are probably just going to cause the server to throw an error.