30 lines
750 B
JavaScript
30 lines
750 B
JavaScript
const express = require("express")
|
|
const app = express()
|
|
const PORT = 3000
|
|
const path = require('path')
|
|
|
|
const { create } = require('express-handlebars');
|
|
|
|
const hbs = create({
|
|
defaultLayout: 'main.hbs', // Domyślny layout: views/layouts/main.hbs
|
|
extname: '.hbs' // rozszerzenie plików szablonów
|
|
});
|
|
|
|
app.engine('.hbs', hbs.engine); // określenie silnika szablonów
|
|
app.set('view engine', '.hbs');
|
|
app.set('views', path.join(__dirname, 'views')); // ustalamy katalog views
|
|
|
|
app.use(express.static("static"))
|
|
|
|
app.get("/index", function (req, res) {
|
|
res.render('index.hbs')
|
|
})
|
|
|
|
app.get("/login", function (req, res) {
|
|
res.render('login.hbs')
|
|
})
|
|
|
|
app.listen(PORT, function () {
|
|
console.log("start serwera na porcie " + PORT)
|
|
})
|