45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const port = 2428;
|
|
|
|
const server = app.listen(port, () => console.log(`Gymrooster running on port ${port}`));
|
|
var path = require('path');
|
|
|
|
var mustacheExpress = require('mustache-express');
|
|
|
|
// Register '.mustache' extension with The Mustache Express
|
|
app.engine('mustache', mustacheExpress());
|
|
|
|
app.set('view engine', 'mustache');
|
|
app.set('views', path.resolve('views/'));
|
|
|
|
app.engine('mustache', mustacheExpress(path.resolve('views/partials/'), '.mustache'));
|
|
|
|
app.use(express.urlencoded());
|
|
|
|
var vars = {
|
|
username: 'ARN'
|
|
}
|
|
|
|
app.get('/', (req, res) => {
|
|
vars.title = 'Home';
|
|
// Render index.mustache and pass variables through.
|
|
res.render('index', vars);
|
|
});
|
|
|
|
app.get('/login/', (req, res) => {
|
|
vars.title = 'Login';
|
|
// Render index.mustache and pass variables through.
|
|
res.render('login', vars);
|
|
});
|
|
|
|
app.post('/login', (req, res) => {
|
|
console.log(req.body)
|
|
res.send('login attempt using the following credentials:');
|
|
});
|
|
|
|
app.get('/scss/:file', (req, res) =>
|
|
res.sendFile(path.resolve('scss/' + req.params.file))
|
|
);
|
|
|