Done Timestamp app / quick notes / few questions

Done Timestamp app / quick notes / few questions
0

#1

So i just finished my timestamp app.

Had some issues with cloud 9 / heroku.

Important things to keep in mind if you do your own:

  • cloud9 only accepted 8080 port
  • yes you can render html and don’t need to use ejs, i was stubborn and wanted to make it work instead of blindly following a guide
  • some things can work perfectly fine locally or even on cloud 9, but they won’t work on heroku
  • don’t forget the Procfile and capitalize the first letter, maybe this was stated in the previous guide, but i had a long break since then and forgot some of the important tiny key details
  • yes you can have it all in one folder unstructured and yes /public whatever folder structure you use can make life easier, but it’s good to know how to do without it if you already know from a guide how to do it with that structure

Question :
So i have the following code:

app.use("/", express.static(__dirname + ‘/’));


app.get(’/’, function(req, res){
res.sendFile(path.join(__dirname+’/index.html’));
});

Second function helps me render the html. But it won’t render the entire set of html + css if i use dirname + ‘/’ apparently. I guess it’s because there’s the server.js and other stuff in the same folder, but i am not sure …

Also adding another line in the second function:
res.sendFile… just to add in the dirname + style.css breaks the app.
Is there any way to use the second function to add in style.css / index.html?

First function seems to be capable to handle the html + css on its own making the second function useless here. Or so it appears on my cloud 9 account at the moment.

When and why do i use the second function. Or when is the second better than the first one?

One last question:
I didn’t see any outstanding reason to use ejs instead of html. Someone please explain why ejs is recommended.

I still don’t like using jade, html looks safer and it’s harder to mess up your code. Is it all just preference based?