Guest User

Untitled

a guest
Jan 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. const express = require('express');
  2. const bodyParser = require('body-parser');
  3. const path = require('path');
  4. const http = require('http');
  5. const app = express();
  6. var fs = require('fs');
  7. //var stream = fs.createReadStream('./today.json');
  8. var data ='';
  9. var heart = require('./today.json');
  10. app.use(bodyParser.json());
  11. app.use(bodyParser.urlencoded({ extended: false}));
  12.  
  13. // Angular DIST output folder
  14. app.use(express.static(path.join(__dirname, 'dist')));
  15. app.get('/aa', function(req, res) {
  16. console.log('adding heart data to response');
  17. res.json(heart);
  18. });
  19.  
  20. //Set Port
  21. const port = process.env.PORT || '3000';
  22. app.set('port', port);
  23.  
  24. const server = http.createServer(app);
  25.  
  26. server.listen(port, function(){
  27. console.log('Running on localhost:'+port)});
  28.  
  29. app.get('*', function(req, res) {
  30. res.sendFile(path.join(__dirname, 'dist/index.html'));
  31. });
Add Comment
Please, Sign In to add comment