Spaces:
Sleeping
Sleeping
ausername-12345 commited on
Commit ·
683ebd7
1
Parent(s): e0d3782
DNS deep check for api-inference
Browse files
server.js
CHANGED
|
@@ -9,8 +9,16 @@ const PORT = process.env.PORT || 7860;
|
|
| 9 |
|
| 10 |
app.use(express.json({ limit: "1mb" }));
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
});
|
| 15 |
|
| 16 |
app.post("/api/hf", async (req, res) => {
|
|
|
|
| 9 |
|
| 10 |
app.use(express.json({ limit: "1mb" }));
|
| 11 |
|
| 12 |
+
import { resolve4, resolveCname, resolveAny } from "dns/promises";
|
| 13 |
+
|
| 14 |
+
app.get("/api/check", async (_, res) => {
|
| 15 |
+
const dns = {};
|
| 16 |
+
for (const host of ["api-inference.huggingface.co", "huggingface.co"]) {
|
| 17 |
+
try { dns[host] = { a: await resolve4(host) }; } catch (e) { dns[host] = { a_error: e.code }; }
|
| 18 |
+
try { dns[host].cname = await resolveCname(host); } catch (e) { dns[host].cname_error = e.code; }
|
| 19 |
+
try { dns[host].any = await resolveAny(host); } catch (e) { dns[host].any_error = e.code; }
|
| 20 |
+
}
|
| 21 |
+
res.json({ ok: true, token: !!process.env.HF_TOKEN, dns });
|
| 22 |
});
|
| 23 |
|
| 24 |
app.post("/api/hf", async (req, res) => {
|