mirror of
https://github.com/blueskychan-dev/blueskychan.dev.git
synced 2025-07-08 07:41:05 +00:00
From bluestar-b requested
This commit is contained in:
parent
94aad46316
commit
e74f2eded4
1 changed files with 11 additions and 0 deletions
|
@ -2,9 +2,20 @@ import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
export default function handler(req, res) {
|
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 random = Math.floor(Math.random() * 3) + 1; // Generate random number 1-3
|
||||||
const imagePath = path.join(process.cwd(), "public", "sekai", `${random}.jpeg`);
|
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
|
// Read the image file from the filesystem
|
||||||
const image = fs.readFileSync(imagePath);
|
const image = fs.readFileSync(imagePath);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue