I am confused what the "/" is used for in this piece of code:
app.get("/", (req, res) =>// The / is a shortcut for index.html (might be right could be wrong)
{
res.render(index);
});
I am confused what the "/" is used for in this piece of code:
app.get("/", (req, res) =>// The / is a shortcut for index.html (might be right could be wrong)
{
res.render(index);
});
Traditional and convenience.
Given the domain example.com
, you want the homepage to be at https://example.com/
(i.e. the path, which comes immediately after the domain name, is /
) so you don't need to type https://example.com/anything-here
.
In your example, the default page of the website, i.e example.com
, would render the index page.
However if you wish to make a different page, such as example.com/about
you would use /about
and render the about page.
e.g. for your code
app.get("[Whatever directory]" ...)
{
res.render([whatever page])
...