In ‘basic node and express’ section I got stuck in the section of ‘use .env file’.
My code is:
let express = require('express');
let app = express();
console.log("Hello World");
app.use('/public', express.static(__dirname + '/public'))
app.get("/",(req, res)=>{
const filePath = __dirname + '/views/index.html';
res.sendFile(filePath);
});
app.get('/json',function(req,res){
const helloJSON = "Hello json";
let message;
if(process.env.MESSAGE_STYLE === 'uppercase'){
message = helloJSON.toUpperCase();
}else{
message=helloJSON;
}
const data={
"message":message;
};
res.json(data);
})
module.exports = app;