-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapp.js
More file actions
67 lines (61 loc) · 2.89 KB
/
Copy pathapp.js
File metadata and controls
67 lines (61 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const http = require('http');
const hostname = 'localhost';
const port = 3000;
var friends = require("./friends.json"); // Once for all times
const server = http.createServer((request, response) => {
response.statusCode = 200;
response.setHeader('Content-type', 'text/html');
response.write(
'<!DOCTYPE html> \n' +
'<html lang="en"> \n' +
' <head> \n' +
' <meta charset="utf-8"> \n' +
' <meta http-equiv="X-UA-Compatible" content="IE=edge"> \n' +
' <meta name="viewport" content="width=device-width, initial-scale=1"> \n' +
' <meta name="description" content="Home Page"> \n' +
' <meta name="author" content="Carlos Arias"> \n' +
' <title>Netcentric Computing Home Page</title> \n' +
' <!-- Bootstrap core CSS --> \n' +
' <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">\n' +
' </head> \n' +
' <body> \n' +
' <div class="container" style="text-align: center"> \n' +
' <h1>Another Example of Node</h1><br> \n'
);
var currentDate = new Date();
response.write(
' <p>Current time is: ' + currentDate + '</p>'
);
response.write(
' <table class="table table-bordered table-hover"> \n' +
' <thead> \n' +
' <tr> \n' +
' <th scope="col">First Name</th> \n' +
' <th scope="col">Last Name</th> \n' +
' <th scope="col">Phone</th> \n' +
' </tr> \n' +
' </thead> \n' +
' <tbody> \n'
);
for (var key in friends)
for (var f in friends[key])
response.write(
' <tr> \n' +
' <td>' + friends[key][f]["firstName"] + '</td> \n' +
' <td>' + friends[key][f]["lastName"] + '</td> \n' +
' <td>' + friends[key][f]["phone"] + '</td> \n' +
' </tr> \n'
);
response.write(
' </tbody> \n' +
' </table> \n'
);
response.write(
' </body> \n' +
'</html> \n'
);
response.end();
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});