CS4201_Assignment (1)
CS4201_Assignment (1)
Cyber Security
const
http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write('<h1>Welcome to my Node.js Server!</h1>');
res.end();
});
server.listen(3000, () => {
console.log('Server running at http://localhost:3000');
});
2. Display the Current Date and Time in the Browser
6. Event Handling
c. Setting the Status Code
d. Parsing Data from Request
e. Demonstrating GET, POST, PUT, and DELETE Requests
f. Using Middleware to Log Request Details
app.use(express.static('public'));
h. Returning JSON Data from an API