2👍
Just add this line of code
app.use(express.static(path.join(__dirname, 'public')));
So you code would look like this
const express = require('express');
const path = require('path');
const app = express();
const port = process.env.PORT || 1234;
app.use(express.static(path.join(__dirname, 'public')));
// sendFile will go here
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname, '/public/index.html'));
});
app.listen(port);
console.log('Server started at http://localhost:' + port);
- [Vuejs]-How can i pull form values to another page
- [Vuejs]-Long polling in Vue.js and Vuex that's independent of components' lifecycle, where to store hot observables for "unsubscribe"?
Source:stackexchange.com