A small Workers app to deploy on g1t.page
3 files+32−00/3 viewed
| 1 | + | <!doctype html> | |
| 2 | + | <html lang="en"> | |
| 3 | + | <head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>automation-lab</title></head> | |
| 4 | + | <body style="font-family: system-ui; background: #121214; color: #ececf1; padding: 3rem"> | |
| 5 | + | <h1>automation-lab, on g1t.page</h1> | |
| 6 | + | <p id="api">Asking the Worker…</p> | |
| 7 | + | <script>fetch("/api").then((r) => r.json()).then((d) => (document.getElementById("api").textContent = JSON.stringify(d)));</script> | |
| 8 | + | </body> | |
| 9 | + | </html> |
| 1 | + | // /api says what this deployment was given; everything else is the site. | |
| 2 | + | export default { | |
| 3 | + | async fetch(request, env) { | |
| 4 | + | const url = new URL(request.url); | |
| 5 | + | if (url.pathname === "/api") { | |
| 6 | + | return Response.json({ | |
| 7 | + | fromConfig: env.FROM_CONFIG ?? null, | |
| 8 | + | greeting: env.GREETING ?? null, | |
| 9 | + | // Only a prefix: enough to tell the test key from the live one. | |
| 10 | + | stripeKey: env.STRIPE_KEY ? `${env.STRIPE_KEY.slice(0, 8)}…` : null, | |
| 11 | + | }); | |
| 12 | + | } | |
| 13 | + | return env.ASSETS.fetch(request); | |
| 14 | + | }, | |
| 15 | + | }; |
| 1 | + | { | |
| 2 | + | // A small Workers app, to show g1t.page deploying one. | |
| 3 | + | "name": "automation-lab", | |
| 4 | + | "main": "src/index.js", | |
| 5 | + | "compatibility_date": "2026-09-26", | |
| 6 | + | "assets": { "directory": "public", "binding": "ASSETS" }, | |
| 7 | + | "vars": { "FROM_CONFIG": "set in wrangler.jsonc" } | |
| 8 | + | } |