-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (23 loc) · 982 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const express = require('express');
const axios = require('axios');
const app = express();
app.get('/', async (req, res) => {
try {
const apiUrl = 'https://brutalist.report/api/v1/articles/discord';
const response = await axios.get(apiUrl);
const articles = response.data.articles;
let htmlContent = '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>API Data</title></head><body>';
articles.forEach(article => {
htmlContent += `<h3><a href="${article.url}">${article.title}</a></h3>`;
});
htmlContent += '</body></html>';
res.send(htmlContent);
} catch (error) {
console.error(error);
res.status(500).send('Bir hata oluştu.');
}
});
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});