cmda-bt / be-course-17-18

๐ŸŽ“ Backend ยท 2017-2018 ยท Curriculum and Syllabus ๐Ÿ’พ
Other
47 stars 19 forks source link

Listing assignment #508

Closed iamDistractech closed 6 years ago

iamDistractech commented 6 years ago

repo

I liked the assignments, but couldn't get everything working the way I want.

for example if you ask for "localhost:8000/images" it uses the css. but if you add a forward slash / to it it doesn't use the css. Tried fixing it, but I couldn't get it to work.

rijkvanzanten commented 6 years ago

Hey @iSirThijs

The CSS on /images/ doesn't get loaded, because the link tag is setup with a relative url style.css, so it looks in the current folder for the file. On /images/, it'll try to fetch /images/style.css, while it should get /style.css. You can fix this by adding the / in front of the file name in the link tag! ๐Ÿ˜„

Feedback

Repo

Code

// before
if (err) {
        if (err.code == 'EISDIR') {
          doSomething()
        }
}

// after
if (err && err.code === 'EISDIR') {
  doSomething()
}

or you could use the fact that a function stops doing anything after you return a value. This pattern is often used in this case

function onRead(err, file) {
  if (err) return notFound(res); // this will stop the function

  return sendPage(file);
}

Functionality

All in all, good job ๐ŸŽ‰