WebNov 25, 2015 · app.get ('/',function (req,res) That's for the URL: localhost:3000/. But, the URL in your image is localhost:3000/about.html which you do not have a route for. So, you can either make a route for that particular URL or you can use express.static () to automatically serve files from a particular directory. WebJan 8, 2016 · 1 Answer. When you check the server.js that comes with the OpenShift's nodejs cartridge, you'll see there that there is the / route defined to serve the index file: self.routes ['/'] = function (req, res) { res.setHeader ('Content-Type', 'text/html'); res.send (self.cache_get ('index.html') ); }; ...therefore you will get the index file, when ...
Cannot GET /index.html. when following tutorial on Node.js and …
WebJan 4, 2024 · The correct way to serve static files with express is as follows: //Look for statics first app.use (express.static (path.join (__dirname, 'public'))); //Return the index for any other GET request app.get ('/*', function (req, res) { res.sendFile ('index.html', {root: path.join (__dirname, 'public')}); }); WebJun 10, 2015 · You seem to have created two instances of express which may be your problem. Try changing: var express = require ('express'); var app = express (); var router = express (); var server = http.createServer (router); to: var express = require ('express'); var app = express (); var server = http.createServer (app); lookup cna license maryland
javascript - Angular: Cannot Get / - Stack Overflow
WebMar 11, 2016 · Teams. Q&A for work. Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams WebAug 21, 2016 · index.js: var express = require ('express'); var router = express.Router (); /* GET home page. */ router.get ('/', function (req, res, next) { res.render ('index.html'); }); module.exports = router; Here is also a screenshot of my … WebDec 25, 2010 · If you're using express@~3.0.0 change the line below from your example:. app.use(express.staticProvider(__dirname + '/public')); to something like this: app.set("view ... look up cna license number south carolina