Sunday, 12 March 2017

expressjs Cannot GET/ error, can not reach to any file in other folders

I am just trying to create a very simple server with expressJS , just to get data for my Angular application but I couldnt find any solution for that error, which is displayed in the browser ' Cannot GET/ ' .

The code of webserver I tried to create ;

var express = require('express');
var path = require('path');

var app = express();

var rootPath = path.normalize(__dirname + '/../');

app.use(express.static(rootPath + '/app'));

app.listen(8000);

console.log('Listening on port 8000  ');

basically what I am trying to do is when i visit the localhost:8000/EventDetails.html the page should be shown. ( this is why I am using /../)



via Hasan Uzun

No comments:

Post a Comment