const routes = {
'/'
: (req, res) => {
res.writeHead(200, {
'Content-Type'
:
'text/plain'
});
res.end(
'Welcome to GeeksforGeeks'
);
},
'/about'
: (req, res) => {
res.writeHead(200, {
'Content-Type'
:
'text/plain'
});
res.end(`GeeksforGeeks is a leading platform that provides
computer science resources and coding challenges
for
programmers
and technology enthusiasts, along
with
interview and
exam preparations
for
upcoming aspirants.`);
},
'/contact'
: (req, res) => {
res.writeHead(200, {
'Content-Type'
:
'text/plain'
});
res.end(`A-143, 9th Floor, Sovereign Corporate Tower,
Sector-136, Noida, Uttar Pradesh - 201305 `);
},
};
function
route(pathname, req, res) {
if
(
typeof
routes[pathname] ===
'function'
) {
routes[pathname](req, res);
}
else
{
res.writeHead(404, { 'Content-Type
': '
text/plain
' });
res.end('
404 Not Found');
}
}
module.exports = {
route,
};