diff --git a/index.js b/index.js index 2b83a68..d29e74e 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,16 @@ -const express = require('express') +const express = require('express'), +path = require("path"), +fs = require("fs") const PORT = process.env.PORT || 8080 var app = express() +function randomFileInDir(directory) { + var dir = fs.readdirSync(directory) + return path.join(directory, dir[Math.floor(Math.random() * dir.length)]) +} + app.get("/", (req, res) => { res.send({ info: "Welcome to the API! It's still a work in process, so there's not much here yet. I don't really know how to do APIs yet so expect it to suck if I add anything.", @@ -16,6 +23,10 @@ app.get("/", (req, res) => { }) }) +app.get("/v1/pfp", (req, res) => { + res.sendFile(randomFileInDir(path.join(__dirname, 'pfps'))) +}) + app.listen(PORT, () => { console.log("API is now listening on port 8080!") }) \ No newline at end of file diff --git a/pfps/MiseryBedAngry.png b/pfps/MiseryBedAngry.png new file mode 100644 index 0000000..c15e8e7 Binary files /dev/null and b/pfps/MiseryBedAngry.png differ diff --git a/pfps/MiseryBedHappy.png b/pfps/MiseryBedHappy.png new file mode 100644 index 0000000..b00d10c Binary files /dev/null and b/pfps/MiseryBedHappy.png differ diff --git a/pfps/MiseryBedNeutral.png b/pfps/MiseryBedNeutral.png new file mode 100644 index 0000000..f65ccbe Binary files /dev/null and b/pfps/MiseryBedNeutral.png differ diff --git a/pfps/MiserySantaAngry.png b/pfps/MiserySantaAngry.png new file mode 100644 index 0000000..bffdff9 Binary files /dev/null and b/pfps/MiserySantaAngry.png differ diff --git a/pfps/MiserySantaHappy.png b/pfps/MiserySantaHappy.png new file mode 100644 index 0000000..f051e0f Binary files /dev/null and b/pfps/MiserySantaHappy.png differ diff --git a/pfps/MiserySantaNeutral.png b/pfps/MiserySantaNeutral.png new file mode 100644 index 0000000..4e11183 Binary files /dev/null and b/pfps/MiserySantaNeutral.png differ