-1

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);
}); 
MARSHMALLOW
  • 1,315
  • 2
  • 12
  • 24
  • 2
    Try looking at the URL path as an actual file-system path, where `/` is the *root directory*. On Unix and Unix-like systems (for example Linux or macOS) the `/` is the actual file-system root directory, and also acts as directory separator. – Some programmer dude Mar 28 '20 at 11:32

2 Answers2

1

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.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

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])
...
appledoes
  • 113
  • 9