Skip to content

Commit

Permalink
cleaned up html template
Browse files Browse the repository at this point in the history
  • Loading branch information
jbergfeld committed Sep 29, 2024
1 parent 1c3ce6f commit 086e604
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
12 changes: 4 additions & 8 deletions src/app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const client = new Pool({connectionString: dbconnection});

var databaseresults = '';
var port = process.env.PORT || 8080;
var message = process.env.MESSAGE || 'Hello world!';
var message = process.env.MESSAGE || 'Hello World';
var renderPathPrefix = (
process.env.RENDER_PATH_PREFIX ?
'/' + process.env.RENDER_PATH_PREFIX.replace(/^[\\/]+/, '').replace(/[\\/]+$/, '') :
Expand All @@ -34,14 +34,12 @@ var handlerPathPrefix = (
''
);

var githubRepo = 'https://github.com/jbergfeld/hello-kubernetes';
var namespace = process.env.KUBERNETES_NAMESPACE || '-';
var podName = process.env.KUBERNETES_POD_NAME || os.hostname();
var nodeName = process.env.KUBERNETES_NODE_NAME || '-';
var nodeOS = os.type() + ' ' + os.release();
var database = dbconnection;
var applicationVersion = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
var containerImage = process.env.CONTAINER_IMAGE || 'paulbouwer/hello-kubernetes:' + applicationVersion
var containerImageArch = JSON.parse(fs.readFileSync('info.json', 'utf8')).containerImageArch;
var wizfilecontents = JSON.parse(fs.readFileSync('wizexercise.txt', 'utf8')).contents;

logger.debug();
Expand All @@ -54,7 +52,6 @@ logger.debug('HANDLER_PATH_PREFIX=' + process.env.HANDLER_PATH_PREFIX);
logger.debug('KUBERNETES_NAMESPACE=' + process.env.KUBERNETES_NAMESPACE);
logger.debug('KUBERNETES_POD_NAME=' + process.env.KUBERNETES_POD_NAME);
logger.debug('KUBERNETES_NODE_NAME=' + process.env.KUBERNETES_NODE_NAME);
logger.debug('CONTAINER_IMAGE=' + process.env.CONTAINER_IMAGE);

// Handlers

Expand All @@ -71,11 +68,10 @@ logger.debug('Serving from base path "' + handlerPathPrefix + '"');
app.get(handlerPathPrefix + '/', function (req, res) {
res.render('home', {
message: message,
namespace: namespace,
pod: podName,
node: nodeName + ' (' + nodeOS + ')',
node: nodeOS,
database: database,
container: containerImage + ' (' + containerImageArch + ')',
footer: githubRepo,
data: databaseresults,
wizfile: wizfilecontents,
renderPathPrefix: renderPathPrefix
Expand Down
10 changes: 3 additions & 7 deletions src/app/views/home.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@
</div>
<div id="info">
<table>
<tr>
<th>namespace:</th>
<td>{{ namespace }}</td>
</tr>
<tr>
<th>pod:</th>
<td>{{ pod }}</td>
</tr>
<tr>
<th>node:</th>
<th>node OS:</th>
<td>{{ node }}</td>
</tr>
<tr>
<th>database:</th>
<td>{{ database }}</td>
</tr>
<tr>
<th>data:</th>
<th>query results:</th>
<td>{{ data }}</td>
</tr>
<tr>
Expand All @@ -30,5 +26,5 @@
</table>
</div>
<div id="footer">
{{ container }}
{{ footer }}
</div>

0 comments on commit 086e604

Please sign in to comment.