Anzeige der HTML -Datei in der Node JS -AnwendungHTML

HTML-Programmierer
Anonymous
 Anzeige der HTML -Datei in der Node JS -Anwendung

Post by Anonymous »

Ich bin neu auf node.js und ich habe eine App.js -Datei wie: < /p>

Code: Select all

const express = require('express');
const app = express();
const port = 8080;
app.get('/', (req, res) => res.send('Hello World'));
app.listen(port);
console.log(`App running on http://localhost:${port}`);

< /code>
Ich habe auch die Datei der index.html im selben Ordner mit app.js. Hier gibt es eine HTML5 -Website. anstelle von Hello World?app.get('/',function(req,res) {
res.sendFile('index.html');
});
, aber keinen Unterschied gesehen.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post