Initial commit

main
Nightly 2022-10-17 10:07:07 +02:00
commit 71c4ec6d74
7 changed files with 57 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

27
Components/webserver.js Normal file
View File

@ -0,0 +1,27 @@
// Import things
const express = require('express');
const app = express();
const server = require('http').createServer(app);
const port = process.env.PORT || 3430;
// Set the templates folder for the thingy
app.set('views', __dirname + '/../Templates');
app.set('view engine', 'ejs');
// Makes it so that the Public folder mounts under /
app.use(express.static(__dirname + '/../Public'));
// Main page
app.get('/', function(req, res){
res.render('index');
});
// Simple way to expose a function
exports = module.exports = rws;
// rws = RunWebServer
function rws() {
server.listen(port, () => {
console.log('✅ Webserver is running ( %d )', port);
});
};

3
Public/style.css Normal file
View File

@ -0,0 +1,3 @@
#cssloaded {
color:deepskyblue;
}

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# nodejs-express-ejs
Template repo

15
Templates/index.ejs Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello world!</title>
<!-- Links -->
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1 id="cssloaded">Hello world!</h1>
</body>
</html>

2
index.js Normal file
View File

@ -0,0 +1,2 @@
var rws = require("./Components/webserver.js");
rws();

6
package.json Normal file
View File

@ -0,0 +1,6 @@
{
"dependencies": {
"ejs": "^3.1.8",
"express": "^4.18.1"
}
}