const express = require('express'); const app = express(); const port = 1854; const pfp = require('random-pfp'); app.get('/getRandomLink', async (req, res) => { const axios = require('axios'); const fs = require('fs').promises; const path = require('path'); const downloadAndSaveImage = async () => { const imageUrl = pfp(); const response = await axios.get(imageUrl, { responseType: 'arraybuffer' }); const buffer = Buffer.from(response.data, 'binary'); const fileName = `image_${Date.now()}.png`; const filePath = path.join('/var/www/html/randomPfp/', fileName); await fs.mkdir(path.dirname(filePath), { recursive: true }); await fs.writeFile(filePath, buffer); return filePath; }; const localImagePath = await downloadAndSaveImage(); res.json({ link: pfp(), localLink: `https://vps.playpoolstudios.com/randomPfp/${fileName}` }); }); app.get('/', (req, res)=>{ res.send(``) }) app.listen(port, () => { console.log(`Server running on port ${port}`); });