mirror of
https://github.com/gigirassy/plaster.git
synced 2024-12-23 10:29:07 +00:00
Update app.js
This commit is contained in:
parent
22bb0aa14f
commit
ef98407318
19
app.js
19
app.js
@ -8,6 +8,25 @@ const PORT = process.env.PORT || 3000;
|
|||||||
app.use(express.static('public'));
|
app.use(express.static('public'));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
|
// Environment variable to toggle ASCII art
|
||||||
|
const showAsciiArt = process.env.SHOW_ASCII_ART === 'true';
|
||||||
|
const asciiArtFolder = process.env.ASCII_ART_FOLDER || path.join(__dirname, 'ascii');
|
||||||
|
|
||||||
|
// Get ASCII art files
|
||||||
|
const asciiArtFiles = showAsciiArt ? fs.readdirSync(asciiArtFolder).filter(file => file.endsWith('.txt')) : [];
|
||||||
|
|
||||||
|
// Serve a random ASCII art
|
||||||
|
app.get('/ascii', (req, res) => {
|
||||||
|
if (!showAsciiArt || asciiArtFiles.length === 0) {
|
||||||
|
res.json({ enabled: false });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const randomFile = asciiArtFiles[Math.floor(Math.random() * asciiArtFiles.length)];
|
||||||
|
const art = fs.readFileSync(path.join(asciiArtFolder, randomFile), 'utf-8');
|
||||||
|
res.json({ enabled: true, art });
|
||||||
|
});
|
||||||
|
|
||||||
const autoCopyDefault = process.env.AUTO_COPY_DEFAULT === 'true';
|
const autoCopyDefault = process.env.AUTO_COPY_DEFAULT === 'true';
|
||||||
|
|
||||||
app.get('/auto-copy-default', (req, res) => {
|
app.get('/auto-copy-default', (req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user