Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
Express Renders Pug File to Same URL?

When I fill out my form and submit my data, it renders my order.pug file on the browser, but my URL is still showing just localhost:3000 instead of localhost:3000/order?

My pug file is in a views folder and my express.js file is just on the main directory for my project

Here is my express file

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static(__dirname + "/public"));

app.set("view engine", "pug");

app.get("/orderPug", (req, res) => {
  res.render("orderPug");
});

app.get("/", (req, res) => {
  res.sendFile(path.join(__dirname, "index.html"));
});

Then my post request to accept my data, then render my order.pug file

app.post("/create", async (req, res) => {
 //API Authentication code is here

  
  res.render("order")
});

My Pug File looks like this, so if I just navigate to localhost:3000/order it will show the value hard coded like below.

  h1 Total: $#{totalCost}

But after I submit my form data it ends up looking like this, except the URL is still on localhost:3000

  Total: $100.00

So when I submit my form, it shows the page has updated to order.pug yet the URL still just shows localhost:3000 and I don't think that makes sense for a confirmation page to show?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda