-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (17 loc) · 552 Bytes
/
server.js
File metadata and controls
22 lines (17 loc) · 552 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//This code is available here: https://nodejs.org/en/about/
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
// res.setHeader('Content-Type', 'text/plain');
//res.end('Hello World');
//This will render html file
res.setHeader('Content-Type', 'text/html');
res.end(`
<h1>Hey this is H1</h1>
`);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});