SHARE
TWEET

Untitled

a guest Feb 17th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const path = require('path');
  3. //const bodyParser = require('body-parser');
  4. const app = express();
  5. const port = process.env.PORT || 5000;
  6.  
  7. //app.use(bodyParser.json());
  8. //app.use(bodyParser.urlencoded({ extended: true }));
  9.  
  10. // API calls
  11. // app.get('/api/hello', (req, res) => {
  12. //   res.send({ express: 'Hello From Express' });
  13. // });
  14.  
  15. // app.post('/api/world', (req, res) => {
  16. //   console.log(req.body);
  17. //   res.send(
  18. //     `I received your POST request. This is what you sent me: ${req.body.post}`,
  19. //   );
  20. // });
  21.  
  22. if (process.env.NODE_ENV === 'production') {
  23.   // Serve any static files
  24.   app.use(express.static(path.join(__dirname, '/home/site/wwwroot/build')));
  25.  
  26.   // Handle React routing, return all requests to React app
  27.   app.get('*', function(req, res) {
  28.     res.sendFile(path.join(__dirname, '/home/site/wwwroot/build', 'index.html'));
  29.   });
  30. }
  31.  
  32. //app.listen(port, () => console.log(`Listening on port ${port}`));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top