Static files serving
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
|
||||
app.get("/", (req, res) => res.send("Server alive, with Express!"));
|
||||
|
||||
app.listen(8080, () => console.log("Mini server (with Express) ready at http://localhost:8080/!"));
|
||||
@@ -0,0 +1,22 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const app = express();
|
||||
|
||||
app.get("/", (req, res) => res.send("Server alive, with Express!"));
|
||||
|
||||
app.use(
|
||||
"/static",
|
||||
express.static(path.join(__dirname, "../flags"), {
|
||||
immutable: true,
|
||||
maxAge: "30 days"
|
||||
})
|
||||
);
|
||||
|
||||
app.listen(8080, () =>
|
||||
console.log(
|
||||
"Mini Express static server ready at http://localhost:8080/!"
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,27 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const flagsPath = path.join(__dirname, "../flags");
|
||||
|
||||
app.get("/uruguay", (req, res) =>
|
||||
res.sendFile(`${flagsPath}/america/south/UY.png`)
|
||||
);
|
||||
|
||||
app.get("/england", (req, res) =>
|
||||
res.sendFile(`${flagsPath}/europe/GB.png`)
|
||||
);
|
||||
|
||||
app.get("/license", (req, res) =>
|
||||
res.sendFile(`${flagsPath}/license.txt`)
|
||||
);
|
||||
|
||||
app.listen(8080, () =>
|
||||
console.log(
|
||||
"Mini Express static server ready at http://localhost:8080/!"
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user