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..7cefab5 --- /dev/null +++ b/Components/webserver.js @@ -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); + }); +}; \ 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/Templates/app.ejs b/Templates/app.ejs new file mode 100644 index 0000000..133d050 --- /dev/null +++ b/Templates/app.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" + } +}