ausername-12345 commited on
Commit
f74f567
·
1 Parent(s): 683ebd7

Check HF env vars

Browse files
Files changed (1) hide show
  1. server.js +6 -8
server.js CHANGED
@@ -9,16 +9,14 @@ const PORT = process.env.PORT || 7860;
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) => {
 
9
 
10
  app.use(express.json({ limit: "1mb" }));
11
 
 
 
12
  app.get("/api/check", async (_, res) => {
13
+ const env = {};
14
+ const interesting = ["HF_TOKEN", "HF_API_TOKEN", "HF_INFERENCE_ENDPOINT", "SPACE_ID", "SPACE_TITLE", "HUGGINGFACEHUB_API_TOKEN", "API_TOKEN"];
15
+ for (const key of interesting) {
16
+ if (process.env[key]) env[key] = process.env[key].length > 10 ? process.env[key].slice(0, 8) + "..." : "(set)";
17
+ else env[key] = "(not set)";
18
  }
19
+ res.json({ ok: true, env });
20
  });
21
 
22
  app.post("/api/hf", async (req, res) => {