哈巴狗模板引擎,为什么我无法在浏览器上获取哈巴狗文件

时间:2020-09-28 07:52:11

标签: node.js

这是代码,它告诉我输出无法获取/demo.pug

//import modules here
const express = require("express");

const http = require("http");

const fs = require("fs");

const path = require("path");

const port = 8020;

const app = express();

//express specific stuff

app.use('/static', express.static('static')); //for static files

//pug specific stuff

app.set('view engine', 'pug') // set the engine in pug

app.set("views", path.join(__dirname, "views")); //set the views directory

//Endpoints 

app.get("/demo", (req, res) => {
  res.render('demo', { title: 'Hey', message: 'Hello there! thanks for teaching me how to use pub' })
});
// Start the server

app.listen(port, () => {

  console.log("the application started successfully");
});

0 个答案:

没有答案