I created app.js
file like below:
const express = require('express');
const app = express();
app.use(express.static('public/styles'));
app.use(express.static('public/views'));
app.use(express.static('public/images'));
module.exports = app;
When I add app.listen(8000);
and I start my app by node app.js
everything looks good.
But I wanted to have server in different file so I created server.js
file like below:
const http = require('http');
const app = require('../app');
http.createServer(app).listen(8000);
When I started server by node server.js
I am getting error message:
Failed to load resource: the server responded with a status of
404 (Not Found)
My path:
-server
-bin
-server.js
-public
-images
-styles
-style.css
-views
-index.html
-app.js
How it should looks like? What's wrong? Please explain me precisely.
I also tried to use it in server.js
but didn't work:
const app = require('../app');
app.listen(8000);