This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Sectional Comments and Formatting code
- Loading branch information
Reydescel Rodriguez
committed
Feb 27, 2021
1 parent
763a61b
commit a45fc49
Showing
1 changed file
with
66 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,87 @@ | ||
var express = require("express"); | ||
const { exec } = require("child_process"); | ||
var path = require('path'); | ||
/** | ||
* Module Dependencies | ||
*/ | ||
const express = require('express'); | ||
const path = require('path'); | ||
const { exec } = require('child_process'); | ||
|
||
/** | ||
* Server Settings | ||
*/ | ||
var app = express(); | ||
var port = 8000; | ||
|
||
app.set('port', port); | ||
|
||
/** | ||
* Serving Static Files | ||
*/ | ||
app.use(express.static(path.join(__dirname, 'site/html'))); | ||
app.use('/server/vital', express.static(path.join(__dirname, 'vital/public'))); | ||
app.use('/pages/', express.static(path.join(__dirname, 'vital/pages'))) | ||
app.use(function(req, res, next) { | ||
res.status(404); | ||
res.sendFile(path.join(__dirname, 'vital', '404.html')); | ||
}); | ||
|
||
app.use('/pages/', express.static(path.join(__dirname, 'vital/pages'))); | ||
|
||
app.listen(port); | ||
console.log(`Now listening on port ${port}`); | ||
console.log(`Go to http://localhost:${port}`); | ||
/** | ||
* Handling 404 Errors and Displaying 404 Page | ||
*/ | ||
app.use(function (req, res, next) { | ||
res.status(404); | ||
res.sendFile(path.join(__dirname, 'vital', '404.html')); | ||
}); | ||
|
||
exec("node index.js", (error, stdout, stderr) => { | ||
if (error) { | ||
console.log(`error: ${error.message}`); | ||
return; | ||
} | ||
if (stderr) { | ||
console.log(`stderr: ${stderr}`); | ||
return; | ||
} | ||
console.log(`stdout: ${stdout}`); | ||
/** | ||
* Server listening | ||
*/ | ||
app.listen(app.get('port'), function () { | ||
console.log(` | ||
Now listening on port ${port} | ||
Go to http://localhost:${port} | ||
`); | ||
}); | ||
|
||
function site(){ | ||
exec("npm run convert", (error, stdout, stderr) => { | ||
/** | ||
* TODO: Add the description of this function | ||
* [exec description] | ||
* @param {[type]} error [description] | ||
* @param {[type]} stdout [description] | ||
* @param {[type]} stderr [description] | ||
*/ | ||
exec('node index.js', (error, stdout, stderr) => { | ||
if (error) { | ||
console.log(`error: ${error.message}`); | ||
return; | ||
} | ||
|
||
if (stderr) { | ||
console.log(`stderr: ${stderr}`); | ||
return; | ||
} | ||
|
||
console.log(`stdout: ${stdout}`); | ||
}); | ||
|
||
/** | ||
* TODO: Add the description of this function | ||
* [site description] | ||
* [exec description] | ||
* @param {[type]} error [description] | ||
* @param {[type]} stdout [description] | ||
* @param {[type]} stderr [description] | ||
*/ | ||
function site() { | ||
exec('npm run convert', (error, stdout, stderr) => { | ||
if (error) { | ||
console.log(`error: ${error.message}`); | ||
return; | ||
} | ||
|
||
if (stderr) { | ||
console.log(`stderr: ${stderr}`); | ||
return; | ||
} | ||
|
||
console.log(`stdout: ${stdout}`); | ||
}); | ||
} | ||
|
||
site(); | ||
setInterval(site, 600000); |