index.js 458 Bytes
Newer Older
Pithon Kabiro's avatar
Pithon Kabiro committed
1
const express = require("express");
Pithon Kabiro's avatar
Pithon Kabiro committed
2
const favicon = require("express-favicon");
Pithon Kabiro's avatar
Pithon Kabiro committed
3
4
5
6
7
8

const app = express();
const port = process.env.PORT || 3000;

app.use(express.static("public"));

Pithon Kabiro's avatar
Pithon Kabiro committed
9
10
app.use(favicon(__dirname + "/public/favicon.ico"));

Pithon Kabiro's avatar
Pithon Kabiro committed
11
12
13
14
app.get("/", (req, res) => {
  res.sendFile(__dirname + "/index.html");
});

Pithon Kabiro's avatar
Pithon Kabiro committed
15
16
17
18
app.get("/index.html", (req, res) => {
  res.redirect("/");
});

Pithon Kabiro's avatar
Pithon Kabiro committed
19
20
21
app.listen(port, () => {
  console.log(`App listening at localhost:${port}`);
});