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

175
Views
Estoy tratando de hacer una barra de navegación de página usando el marco express y la biblioteca pug cuando llegué a la página de demostración de mi punto final, no obtuve nada en mi pantalla. por favor
enter code here

//Aquí está mi código app.js, quiero hacer una barra de navegación de enrutamiento básica, aquí demo es mi nombre de archivo. Quiero insertar algo de HTML en la página de demostración, pero no aparece nada en la pantalla del navegador.

 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. Elimine los acentos graves al final de su archivo,

  2. Incluya esta línea en su archivo: const express = require("express");

  3. Puede usar EJS en lugar de pug. Es más popular y más fácil de escribir y entender.

  4. Suponiendo que tiene una carpeta de views en la raíz, puede eliminar esta línea:

 // Set the views directory app.set("views", path.join(__dirname, "views"));
  1. Agregar una res más hará que su código se vea más elegante y también con menos errores (por ejemplo, la línea de mensaje no debe tener una coma al final):
 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!" }); });

Revisé su código en mi computadora y funcionó. Intente los pasos anteriores y avíseme si funciona.

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!