commit
66829ceba5
6 changed files with 186 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||||
|
Logs |
||||
|
logs |
||||
|
*.log |
||||
|
npm-debug.log* |
||||
|
yarn-debug.log* |
||||
|
yarn-error.log* |
||||
|
|
||||
|
# Runtime data |
||||
|
pids |
||||
|
*.pid |
||||
|
*.seed |
||||
|
*.pid.lock |
||||
|
|
||||
|
# Directory for instrumented libs generated by jscoverage/JSCover |
||||
|
lib-cov |
||||
|
|
||||
|
# Coverage directory used by tools like istanbul |
||||
|
coverage |
||||
|
|
||||
|
# nyc test coverage |
||||
|
.nyc_output |
||||
|
|
||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) |
||||
|
.grunt |
||||
|
|
||||
|
# Bower dependency directory (https://bower.io/) |
||||
|
bower_components |
||||
|
|
||||
|
# node-waf configuration |
||||
|
.lock-wscript |
||||
|
|
||||
|
# Compiled binary addons (http://nodejs.org/api/addons.html) |
||||
|
build/Release |
||||
|
|
||||
|
# Dependency directories |
||||
|
node_modules/ |
||||
|
jspm_packages/ |
||||
|
|
||||
|
# Typescript v1 declaration files |
||||
|
typings/ |
||||
|
|
||||
|
# Optional npm cache directory |
||||
|
.npm |
||||
|
|
||||
|
# Optional eslint cache |
||||
|
.eslintcache |
||||
|
|
||||
|
# Optional REPL history |
||||
|
.node_repl_history |
||||
|
|
||||
|
# Output of 'npm pack' |
||||
|
*.tgz |
||||
|
|
||||
|
# Yarn Integrity file |
||||
|
.yarn-integrity |
||||
|
|
||||
|
# dotenv environment variables file |
||||
|
.env |
||||
|
|
||||
@ -0,0 +1,2 @@ |
|||||
|
doc |
||||
|
LICENSE |
||||
@ -0,0 +1,21 @@ |
|||||
|
The MIT License (MIT) |
||||
|
|
||||
|
Copyright (c) 2016 Nicolas MASSE |
||||
|
|
||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
of this software and associated documentation files (the "Software"), to deal |
||||
|
in the Software without restriction, including without limitation the rights |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
||||
@ -0,0 +1,14 @@ |
|||||
|
{ |
||||
|
"name": "openshift-demo-nodejs-front", |
||||
|
"version": "0.1.0", |
||||
|
"description": "An OpenShift Demo app running on NodeJS", |
||||
|
"main": "server.js", |
||||
|
"scripts": { |
||||
|
"test": "echo \"Error: no test specified\" && exit 1" |
||||
|
}, |
||||
|
"author": "Nicolas MASSE", |
||||
|
"license": "MIT", |
||||
|
"dependencies": { |
||||
|
"express": "latest" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
var express = require("express"); |
||||
|
var app = express(); |
||||
|
var router = express.Router(); |
||||
|
var port = 8080; |
||||
|
|
||||
|
var color = "red"; |
||||
|
|
||||
|
router.use(function (req,res,next) { |
||||
|
next(); |
||||
|
console.log("%s %s => %i", req.method, req.originalUrl, res.statusCode); |
||||
|
}); |
||||
|
|
||||
|
router.get("/",function(req,res){ |
||||
|
res.sendFile(__dirname + '/views/index.html'); |
||||
|
}); |
||||
|
|
||||
|
router.get("/info",function(req,res){ |
||||
|
var response = { |
||||
|
color: color, |
||||
|
podName: process.env["HOSTNAME"], |
||||
|
}; |
||||
|
res.type('application/json').send(JSON.stringify(response)); |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
app.use("/",router); |
||||
|
|
||||
|
app.use("*",function(req,res){ |
||||
|
res.status(404).send("Not found"); |
||||
|
}); |
||||
|
|
||||
|
app.listen(port,function(){ |
||||
|
console.log("Live at Port %i", port); |
||||
|
}); |
||||
@ -0,0 +1,56 @@ |
|||||
|
<!doctype html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<title>OpenShift Demo</title> |
||||
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js" |
||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" |
||||
|
crossorigin="anonymous"></script> |
||||
|
<style type="text/css"> |
||||
|
<!-- |
||||
|
|
||||
|
body { |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
background-color: lightgray; |
||||
|
} |
||||
|
body > div { |
||||
|
width: 300px; |
||||
|
height: 300px; |
||||
|
background-color: gray; |
||||
|
|
||||
|
position:absolute; |
||||
|
left:0; right:0; |
||||
|
top:0; bottom:0; |
||||
|
margin:auto; |
||||
|
overflow:auto; |
||||
|
text-align: center; |
||||
|
font-family: Arial, Helvetica, "sans-serif"; |
||||
|
font-size: xx-large; |
||||
|
} |
||||
|
.message { |
||||
|
padding-top: 50px; |
||||
|
} |
||||
|
--> |
||||
|
</style> |
||||
|
<script type="text/javascript"> |
||||
|
$().ready(function() { |
||||
|
$.get("/info", function(data) { |
||||
|
if (data.podName) { |
||||
|
$("#pod-name").text(data.podName); |
||||
|
} |
||||
|
$("#box").css("background-color", data.color); |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div id="box"> |
||||
|
<div class="message"> |
||||
|
Hello from <span id="pod-name">unknown</span> ! |
||||
|
</div> |
||||
|
</div> |
||||
|
</body> |
||||
|
</html> |
||||
Loading…
Reference in new issue