coyotte508 HF staff commited on
Commit
cd60ce3
·
verified ·
1 Parent(s): 4f1472a

Update server.ts

Browse files
Files changed (1) hide show
  1. server.ts +11 -8
server.ts CHANGED
@@ -2,15 +2,18 @@ import Koa from "koa";
2
 
3
  const app = new Koa();
4
 
 
 
5
  app.use(async (ctx) => {
6
- console.log(ctx.request.url, ctx.request.method);
7
- ctx.body = {
8
- fullUrl: ctx.request.url,
9
- type: typeof ctx.request.url,
10
- query: ctx.request.query,
11
- s3url: await fetch('https://huggingface.co/gpt2/resolve/main/64.tflite', {redirect: "manual"}).then(r => r.headers.get("Location")),
12
- headers: Object.fromEntries(Object.entries(ctx.request.headers)),
13
- env: process.env
 
14
  };
15
  });
16
 
 
2
 
3
  const app = new Koa();
4
 
5
+ let headers;
6
+
7
  app.use(async (ctx) => {
8
+ if (ctx.request.url.startsWith("/img/")) {
9
+ ctx.body = "no image";
10
+ headers = Object.fromEntries(Object.entries(ctx.request.headers));
11
+ return;
12
+ }
13
+
14
+ console.log(ctx.request.url, ctx.request.method);
15
+ ctx.body = {
16
+ headers,
17
  };
18
  });
19