Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const bodyParser = require('body-parser');
- const path = require('path');
- const http = require('http');
- const app = express();
- var fs = require('fs');
- //var stream = fs.createReadStream('./today.json');
- var data ='';
- var heart = require('./today.json');
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({ extended: false}));
- // Angular DIST output folder
- app.use(express.static(path.join(__dirname, 'dist')));
- app.get('/aa', function(req, res) {
- console.log('adding heart data to response');
- res.json(heart);
- });
- //Set Port
- const port = process.env.PORT || '3000';
- app.set('port', port);
- const server = http.createServer(app);
- server.listen(port, function(){
- console.log('Running on localhost:'+port)});
- app.get('*', function(req, res) {
- res.sendFile(path.join(__dirname, 'dist/index.html'));
- });
Add Comment
Please, Sign In to add comment