2024-12-18 21:16:43 +00:00
|
|
|
const express = require('express');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
|
|
|
|
app.use(express.static('public'));
|
|
|
|
|
2024-12-18 21:25:44 +00:00
|
|
|
// Route to fetch Pastebin raw text data using the Paste ID
|
|
|
|
app.get('/:pasteId', async (req, res) => {
|
|
|
|
const pasteId = req.params.pasteId;
|
2024-12-18 21:16:43 +00:00
|
|
|
|
2024-12-18 21:25:44 +00:00
|
|
|
// Construct the raw Pastebin URL
|
|
|
|
const rawUrl = `https://pastebin.com/raw/${pasteId}`;
|
2024-12-18 21:16:43 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await fetch(rawUrl);
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Failed to fetch data from Pastebin');
|
|
|
|
}
|
|
|
|
const text = await response.text();
|
2024-12-18 21:25:44 +00:00
|
|
|
res.send(`<pre>${text}</pre>`);
|
2024-12-18 21:16:43 +00:00
|
|
|
} catch (error) {
|
2024-12-18 21:25:44 +00:00
|
|
|
res.status(500).send(`Error: ${error.message}`);
|
2024-12-18 21:16:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start the server
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
console.log(`Server is running on http://localhost:${PORT}`);
|
|
|
|
});
|