Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
I'm trying to make a page navigation bar using express framework and pug library when I hit my endpoint demo page I got nothing on my screen. please h
enter code here

//Here is my app.js code, I want to make a basic routing navigation bar, here demo is my file name. I want to insert some HTML into the demo page but got nothing on the browser screen

const path = require("path");
const app = express();
const port = 80;

// For serving static files
app.use("/static", express.static("static"));

// Set the template engine as pug
app.set("view engine", "pug");

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

// Our pug demo endpoint
app.get("/demo", (req, res) => {
  res
    .status(200)
    .render("demo", {
      title: "Hey Harry",
      message: "Hello there and thanks for telling me how to use pubG!",
    });
});

app.get("/", (req, res) => {
  res.status(200).send("This is homepage of my first express app with Harry");
});

app.get("/about", (req, res) => {
  res.send("This is about page of my first express app with Harry");
});

app.post("/about", (req, res) => {
  res.send(
    "This is a post request about page of my first express app with Harry"
  );
});
app.get("/this", (req, res) => {
  res.status(404).send("This page is not found on my website cwh");
});

app.listen(port, () => {
  console.log(`The application started successfully on port ${port}`);
});```

    

    
    enter code here
//& Here is my code for demo.pug

  ```html 
      head 
        title=title 
      body 
        h1 = message```
      
 


 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Please remove the backticks at the end of your file,

  2. Please include this line in your file: const express = require("express");

  3. You can use EJS instead of pug. It is more popular and easier to write and understand.

  4. Assuming you have views folder at the root, you can delete this line:

// Set the views directory
app.set("views", path.join(__dirname, "views"));
  1. Adding one more res will make your code look more stylish and also less buggy (For instance, message line shouldn't have comma at the end):
app.get("/demo", (req, res) => {
  res.status(200);
  res.render("demo", {
      title: "Hey Harry",
      message: "Hello there and thanks for telling me how to use pubG!"
  });
});

I checked the your code on my computer and it worked. Please try the steps above and let me know if it works.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!