T
T
Tanya2019-11-25 18:11:26
JavaScript
Tanya, 2019-11-25 18:11:26

How to properly display html page in express.js?

hi
Customized express

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

app.get('/',(req,res) => {
    res.status(200)
    res.sendFile(path.join(__dirname, 'views', 'index.html'))

})
const PORT = process.env.PORT || 3000

app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`)
}) ;

index.html is a blank page for the time being, it should just display a "Hello" message,
but after starting the server I get a message on the page - "Cannot GET /:"
where can there be an error? (
however, in the console there is an error
Refused to load the image ' localhost: 3000/favicon.ico
' because it violates the following Content Security Policy directive: "default-src 'none'". I couldn't remove it, I don't understand what the problem is (

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question