This commit is contained in:
Bingus_Violet 2024-01-20 22:14:18 -06:00
parent 85431a892e
commit 2885b7ae5d
7 changed files with 12 additions and 1 deletions

View file

@ -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!")
})

BIN
pfps/MiseryBedAngry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
pfps/MiseryBedHappy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
pfps/MiseryBedNeutral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
pfps/MiserySantaAngry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
pfps/MiserySantaHappy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
pfps/MiserySantaNeutral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB