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

338
Vistas
localhost replies with CANNOT GET/

This is my code

const express = require('express');
const app = express();

const bodyparser = require('body-parser');
app.use(bodyparser.urlencoded({extended: false}));
app.use(bodyparser.json());

const cors = require('cors');
app.use(cors());

app.use(express.static('website'));

const port = 8000;
const server = app.listen(port, () => {
    console.log('the server is up and running');
    console.log(`in a localhost ${port}`);
})

and i linked it to html page which has the code

<!DOCTYPE html>
<html lang="en"> 
    
    
    <head>
        
        <meta charset="UTF-8">
        
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        
        <title> Hello World!</title>
        
        
        
        <script src='L2Server.js' >  </script>

    </head>

    <body>

<p>Hi!</p>



<script src='L2Server.js' ></script>
    </body>

  





</html>

and when I run the code in the terminal it show that the server is up and running then when I open the localhost in the browser it displays a message with the following "CANNOT GET/" and I tried almost everything to solve this problem but i don't know what is the matter.

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

0

You need to define a route like

app.get('/', function(req, res) {
  // set response here
});

or provide static content from a folder

app.use(express.static(__dirname + '/public'));

In your case place your html code in ./public/index.html and provide it as static content.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Add something like this:

app.get('/', (req, res) => {
    res.send('website');
});

where 'website' is the name of your html

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