Skip to content

Instantly share code, notes, and snippets.

@sijeesh-02
Last active July 7, 2020 06:11
Show Gist options
  • Save sijeesh-02/d773d3b0b6e2c175a1c0b350ee43a370 to your computer and use it in GitHub Desktop.
Save sijeesh-02/d773d3b0b6e2c175a1c0b350ee43a370 to your computer and use it in GitHub Desktop.
Express file for basic server, created for blog post
const express = require("express");
const app = express();
const path = require("path");
const config = {
port: 3000,
};
/**
* all calls to /assets would be taken from
* a new path which is join of current directory (__dirname)
* and
* ../../dist/ui (root/dist/ui)
*/
app.use("/assets", express.static(path.join(__dirname, "../../dist/ui")));
/**
* All calls to express server on path / will serve index.html
* from path root/public
*/
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "../../public", "index.html"));
});
app.listen(config.port, () =>
console.log(`Example app listening at http://localhost:${config.port}`)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment