FSD-I slip 2Create a Node.js file that will convert the output "Full Stack!" into reverse string

 

//Slip 2: Create a Node.js file that will convert the output "Full Stack!" into reverse string

const http = require('http');

const PORT = 3000;

const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });

const input = "Full Stack!";
const reversed = input.split('').reverse().join('');

// Send the output to the browser
res.end(`Original: ${input}\nReversed: ${reversed}`);
});

server.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});

Comments

Popular posts from this blog

Slip 11: Write node js application that transfer a file as an attachment on web and enables browser to prompt the user to download file using express js.

Slip 7 Create a node js file named main.js for event-driven application. There should be a main loop that listens for events, and then triggers a callback function when one of those events is detected.

Slip 1(a) Write an Angular 13 application addition of two numbers using ng-init, ng-model & ng-bind. And also demonstrate ng-show, ng-disabled, ng-click directives on button component.