commit 71c4ec6d74a750a8a7bd7a2394259d9824b7f42e Author: Nightly Date: Mon Oct 17 10:07:07 2022 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/Components/webserver.js b/Components/webserver.js new file mode 100644 index 0000000..46d1f29 --- /dev/null +++ b/Components/webserver.js @@ -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); + }); +}; \ No newline at end of file diff --git a/Public/style.css b/Public/style.css new file mode 100644 index 0000000..1e3d829 --- /dev/null +++ b/Public/style.css @@ -0,0 +1,3 @@ +#cssloaded { + color:deepskyblue; +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f26e1e6 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# nodejs-express-ejs + +Template repo \ No newline at end of file diff --git a/Templates/index.ejs b/Templates/index.ejs new file mode 100644 index 0000000..133d050 --- /dev/null +++ b/Templates/index.ejs @@ -0,0 +1,15 @@ + + + + + + + Hello world! + + + + + +

Hello world!

+ + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..8874219 --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +var rws = require("./Components/webserver.js"); +rws(); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..d9b58df --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "ejs": "^3.1.8", + "express": "^4.18.1" + } +}