MCreeper12731

Handlebars app 2

Apr 8th, 2025
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import express from 'express';
  2. import { dirname, join } from "path";
  3. import { fileURLToPath } from "url";
  4.  
  5. const __dirname = dirname(fileURLToPath(import.meta.url));
  6.  
  7. const app = express();
  8.  
  9. app.set('view engine', 'hbs');
  10. app.set('views', join(__dirname, 'views'));
  11. app.use(express.static(join(__dirname, "public")));
  12. app.use(express.urlencoded({ extended: true }));
  13.    
  14. app.get("/", (req, res) => {
  15.     res.render("index", { title: "Main Page" })
  16. });
  17.  
  18. app.get("/breeds", (req, res) => {
  19.     res.render("breeds", { title: "Cat Breeds" })
  20. });
  21.  
  22. app.get("/adoption", (req, res) => {
  23.     res.render("adoption", { title: "Adoption" })
  24. });
  25.  
  26.  
  27.  
  28. app.listen(3000, () => {
  29.     console.log('Server is running at http://localhost:3000');
  30. });
Advertisement
Add Comment
Please, Sign In to add comment