Skip to content

Instantly share code, notes, and snippets.

@YasushiKobayashi
Last active May 3, 2017 11:06
Show Gist options
  • Save YasushiKobayashi/70074675cd533c8ad1b65c5b3353c4d9 to your computer and use it in GitHub Desktop.
Save YasushiKobayashi/70074675cd533c8ad1b65c5b3353c4d9 to your computer and use it in GitHub Desktop.
use nodejs express server

setup

import express from 'express';
const app = express();

routing

app.get('*', (req, res) => {
  const title = 'title';
  res.send(`<!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
          <title>${title}</title>
    </head>
    <div id="app"></div>
    <script type="text/javascript" charset="utf-8" src="/assets/app.js"></script>
    </body>
    </html>
  `);
});

run server

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`listening on port ${PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment