Reputation: 21
app.get('/',(req,res)=>{
res.send("index.html ");});
app.listen(3000);
console.log("Server Started");
whenever i enter my local host IP address it displays "index.html" text instead of opening index.html file
Upvotes: 1
Views: 108
Reputation: 4188
You are trying to serve an HTML file, so you have to res.sendFile()
.
var express = require('express');
var app = express();
var path = require('path');
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.listen(3000);
Upvotes: 5