Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
Express Send Files in Folder

I have a server with files like this:

- index.js
/client
 -index.html
 -about.html
 -signup.html
 -style.css

In index.js I have a express server.

  • When the user goes to / , it should go to index.html
  • When the user goes to /about.html it should go to about.html etc
  • When the user goes to /style.css it should go to style.css etc..

I know you can do it like this..

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/client/index.html')
})

But I want to make it so that it automatically sends the correct file without having to get each folder.

I know it has something to do with app.use but I am not fully sure how to use it.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Whoops, I never thought it would be this easy-

app.use('/', express.static('client'))

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda