node-static

Node-static example

为君一笑 提交于 2019-12-23 12:42:27
问题 I've been banging my head against the wall trying to figure out what's wrong with this code. I copied it directly from the node-static github repository example, but it doesn't seem to work. The only modification that I made was to the path of the public files (previously was './public'). In my public folder I have an index.html, but when I hit http://localhost:8080/index.html I get nothing. var static = require('node-static'); // // Create a node-static server instance to serve the './public

Serve html file in nodejs server

。_饼干妹妹 提交于 2019-12-22 00:58:28
问题 I've been doing fine until I try to separate my code into routes, controllers and etc. Now I'm getting an error when I try to load the html file. When I go to the link http://localhost:3000/ I'm getting this error Error: ENOENT: no such file or directory, stat '/views/index.html' This is my routes.js code module.exports = function (app) { var userController = require('../controllers/userController'); // app.use(require('express').static('../app/views/index.html')); app.get('/', userController

Serve html file in nodejs server

强颜欢笑 提交于 2019-12-04 22:46:08
I've been doing fine until I try to separate my code into routes, controllers and etc. Now I'm getting an error when I try to load the html file. When I go to the link http://localhost:3000/ I'm getting this error Error: ENOENT: no such file or directory, stat '/views/index.html' This is my routes.js code module.exports = function (app) { var userController = require('../controllers/userController'); // app.use(require('express').static('../app/views/index.html')); app.get('/', userController.renderHomePage); app.post('/find', userController.getUser); app.get('/get', userController.getUsers);