const extension = path.extname(req.url);
let contentType;
switch(extension){
case '.css':
contentType = 'text/css';
break;
case '.js':
contentType = 'text/javascript';
break;
case '.json':
contentType = 'application/json';
break
case '.jpeg':
contentType = 'image/jpeg';
break;
case '.png':
contentType = 'image/png';
break;
case '.txt':
contentType = 'text/plain'
break;
default:
contentType = 'text/html';
}
let filePath = contentType === 'text/html' && req.url === '/'
? path.join(__dirname, 'views.index.html')
: contentType === 'text/html' && req.url.slice(-1) === '/'
? path.join(__dirname,'views',req.url,'index.html')
: contentType === 'type/html'
? path.join(__dirname, 'views', req.url)
: path.join(__dirname, req.url);
const extension = path.extname(req.url);
let contentType;
switch(extension){
case '.css':
contentType = 'text/css';
break;
case '.js':
contentType = 'text/javascript';
break;
case '.json':
contentType = 'application/json';
break
case '.jpeg':
contentType = 'image/jpeg';
break;
case '.png':
contentType = 'image/png';
break;
case '.txt':
contentType = 'text/plain'
break;
default:
contentType = 'text/html';
}
let filePath = contentType === 'text/html' && req.url === '/'
? path.join(__dirname, 'views.index.html')
: contentType === 'text/html' && req.url.slice(-1) === '/'
? path.join(__dirname,'views',req.url,'index.html')
: contentType === 'type/html'
? path.join(__dirname, 'views', req.url)
: path.join(__dirname, req.url);