mirror of
https://github.com/blueskychan-dev/blueskychan.dev.git
synced 2025-07-07 15:21:04 +00:00
From bluestar-b requested
This commit is contained in:
parent
9b998ba98c
commit
6469cb42c2
1 changed files with 11 additions and 0 deletions
|
@ -2,9 +2,20 @@ import path from "path";
|
|||
import fs from "fs";
|
||||
|
||||
export default function handler(req, res) {
|
||||
if (req.method !== "GET") {
|
||||
res.status(405).json({ message: "Method Not Allowed" });
|
||||
return;
|
||||
}
|
||||
|
||||
const random = Math.floor(Math.random() * 3) + 1; // Generate random number 1-3
|
||||
const imagePath = path.join(process.cwd(), "public", "sekai", `${random}.jpeg`);
|
||||
|
||||
// Check if the image file exists
|
||||
if (!fs.existsSync(imagePath)) {
|
||||
res.status(404).json({ message: "Image Not Found" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the image file from the filesystem
|
||||
const image = fs.readFileSync(imagePath);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue