-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (37 loc) · 1.06 KB
/
Copy pathserver.js
File metadata and controls
44 lines (37 loc) · 1.06 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require("express");
const cors = require("cors");
const path = require("path");
require("dotenv").config();
const imageDownloader = require("node-image-downloader");
const app = express();
app.use(cors());
app.use("/public", express.static(__dirname + "/public"));
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ limit: "50mb" }));
app.post("/monitor-get-asset", async (req, res) => {
const { asset } = req.body;
});
app.post("/newimage", async (req, res) => {
imageDownloader({
imgs: [
{
uri: req.body.asset,
filename: "img",
},
],
dest: "./public", //destination folder
})
.then((info) => {
console.log("all done", info);
res.status(200).send("Ad streamed");
})
.catch((error, response, body) => {
console.log("something goes bad!");
console.log(error);
});
res.sendFile(path.join(__dirname, "/ad-display.html"));
});
app.get("/", async (req, res) => {
res.sendFile(path.join(__dirname, "/ad-display.html"));
});
app.listen(process.env.PORT || 4000);