Make the template

main
nightly 2022-09-07 09:10:03 +02:00
parent 5d20735904
commit 285329bbce
6 changed files with 62 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

35
Components/webserver.js Normal file
View File

@ -0,0 +1,35 @@
// Import things
const express = require('express');
const { is } = require('express/lib/request');
const res = require('express/lib/response');
const app = express();
const path = require('path');
const server = require('http').createServer(app);
const port = process.env.PORT || 3430;
var fs = require('fs');;
// Database for the demo site,
var demoDB = [
{
name: "Poggere"
}
];
// Use /Public as the path for css and such
app.set('views', __dirname + '/../Templates');
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/../Public'));
// Main page
app.get('/', function(req, res){
res.render('app', {site:1, db: demoDB});
});
// Simple way to expose a function
exports = module.exports = rws;
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;
}

15
Templates/app.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"
}
}