parent
3ec83fa400
commit
330e2176a6
@ -0,0 +1,24 @@
|
||||
{
|
||||
"development": {
|
||||
"config_id": "development",
|
||||
"app_name": "conf-test",
|
||||
"app_desc": "An app to test environnement variables",
|
||||
"node_port": 3000,
|
||||
"json_indentation": 4,
|
||||
"database": "nodesandbox_env-dev"
|
||||
},
|
||||
"testing": {
|
||||
"config_id": "testing",
|
||||
"database": "nodesandbox_env-tst"
|
||||
},
|
||||
"staging": {
|
||||
"config_id": "staging",
|
||||
"node_port": 8080,
|
||||
"database": "nodesandbox_env-stage"
|
||||
},
|
||||
"production": {
|
||||
"config_id": "production",
|
||||
"node_port": 8080,
|
||||
"database": "nodesandbox_env"
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
const http = require('http');
|
||||
const url = require('url');
|
||||
|
||||
// load config file
|
||||
const config = require(process.cwd() + '/config.json');
|
||||
|
||||
function outputHTML5(status, response, content, title)
|
||||
{
|
||||
response.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8' });
|
||||
response.write(
|
||||
`
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>${title}</title>
|
||||
<style type="text/css">*{ font-family: sans-serif }</style>
|
||||
</head>
|
||||
<body>
|
||||
${content}
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
);
|
||||
response.end();
|
||||
}
|
||||
|
||||
var server = http.createServer(function (request, response) {
|
||||
if(request.url === "/") {
|
||||
|
||||
content = config.staging.config_id;
|
||||
|
||||
outputHTML5(200,response,content,"Server info");
|
||||
}
|
||||
else {
|
||||
outputHTML5(404,response,'Y\'a rien ici',"Oups");
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(80);
|
Loading…
Reference in new issue