-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (23 loc) · 762 Bytes
/
server.js
File metadata and controls
28 lines (23 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require("express");
const path = require("path");
const proxy = require("express-http-proxy");
const app = express();
const port = 3000;
app.get("/static", (req, res) => {
const fileDirectory = path.resolve(__dirname, ".", "static/");
setTimeout(() => {
res.sendFile(req.query.file, { root: fileDirectory }, (err) => {
res.end();
});
}, req.query.delay);
});
app.use("/random-image", proxy("https://picsum.photos/"));
// app.get("/random-image", (req, res) => {
// req.get({ url: "https://picsum.photos/200/300", headers: req.headers });
// setTimeout(() => {
// res.send("Req OK");
// }, req.query.delay);
// });
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});