mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 06:38:46 +00:00
Glances info widget
This commit is contained in:
parent
5198b056cc
commit
321efd08cc
4 changed files with 140 additions and 0 deletions
23
src/pages/api/widgets/glances.js
Normal file
23
src/pages/api/widgets/glances.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { httpProxy } from "utils/proxy/http";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { url } = req.query;
|
||||
|
||||
if (!url) {
|
||||
return res.status(400).json({ error: "Missing Glances URL" });
|
||||
}
|
||||
|
||||
const apiUrl = `${url}/api/3/quicklook`;
|
||||
const params = { method: "GET", headers: {
|
||||
"Accept-Encoding": "application/json"
|
||||
} };
|
||||
|
||||
const [status, contentType, data, responseHeaders] = await httpProxy(apiUrl, params);
|
||||
|
||||
if (status !== 200) {
|
||||
logger.error("HTTP %d getting data from glances API %s. Data: %s", status, apiUrl, data);
|
||||
}
|
||||
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
return res.status(status).send(data);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue