Skip to content

Commit

Permalink
enhance output
Browse files Browse the repository at this point in the history
  • Loading branch information
mabunixda committed Jul 14, 2022
1 parent 3bb3491 commit a4f6cd7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
9 changes: 9 additions & 0 deletions colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ function handleIdx(req, res) {
}
}

const headerItemList = []

for (const headerItem of Object.keys(req.headers).sort()) {
headerItemList.push(`<tr><td>${headerItem}:</td><td>${req.headers[headerItem]}</td></tr>`);
}

const htmlFile = 'index.html';
res.statusCode = 200;
res.setHeader("Content-Type", "text/html; charset=utf-8");
Expand All @@ -126,9 +132,12 @@ function handleIdx(req, res) {
res.writeHead(404);
res.write('Whoops! File not found!');
} else {

data = data.replace(/\$background_color/g, mycolor);
data = data.replace(/\$font_color/g, font_color);
data = data.replace(/\$hostname/g, hostname);
data = data.replace(/\$headers/g, headerItemList.join('\n'))

res.write(data);
}
res.end();
Expand Down
45 changes: 30 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@
width: 100%;
height: 100%;
position: relative;
background-color: $background_color;
background-color: "$background_color";
font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';
}

td:first-of-type {
white-space: nowrap;
}

.highlight {
color: #7389ff;
font-size: 2em;
}

.center {
Expand All @@ -35,24 +45,29 @@
font-family: "Trebuchet MS", Helvetica, sans-serif;
text-align: center;
}

h1 {
font-size: 144px;
}

p {
font-size: 64px;
}
</style>
</head>

<body>
<div class="center">
<h1>Hello Again!</h1>
<h3>$background_color app</h3>
<p>$hostname</p>
<div>$font_color</div>
</div>
<table id="source" cellpadding="10">
<tr>
<td colspan=2>
<h1>Hello Again!</h1>
</td</tr> <tr>
<td colspan=2>&nbsp;</td</tr> <tr>
<td>Coloring</td>
<td>$background_color app</td>
</tr>
<tr>
<td>Hostname:</td>
<td>$hostname</td>
</tr>
<tr>
<td>Font color</td>
<td>$font_color</td>
</tr>
$headers
</table>
</body>

</html>

0 comments on commit a4f6cd7

Please sign in to comment.