Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function handler(req) {
- const apiKey = Deno.env.get("API_KEY");
- const secret = Deno.env.get("API_SECRET");
- if (secret !== req.headers.get("X-Secret")) {
- return new Response("Hello world", { status: 200 });
- }
- return await fetch("https://api.openai.com/v1/engines/code-cushman-001/completions", {
- headers: {
- ...req.headers,
- "Content-Type": "application/json",
- Authorization: `Bearer ${apiKey}`,
- },
- method: req.method,
- body: req.body,
- });
- }
- console.log("Listening on http://localhost:8080");
- await listenAndServe(":8080", handler);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement