| Nov | DEC | Jan |
| 23 | ||
| 2024 | 2025 | 2026 |
COLLECTED BY
Collection: Focused Crawls
import OpenAI from "openai";
export default async (req: Request) => {
if (req.method !== "POST") {
return new Response("Method not allowed", { status: 405 });
}
try {
const { description } = await req.json();
if (!description) {
return new Response("Missing description", { status: 400 });
}
const client = new OpenAI();
const res = await client.responses.create({
model: "gpt-5-mini",
input: [
{ role: "user", content: `Write concise alt text for: ${description}` },
],
});
return Response.json({ altText: res.output_text });
} catch {
return new Response("Server error", { status: 500 });
}
};
export const config = {
path: "/api/alt-text",
};
import type { Context, Config } from "@netlify/functions";
export default async (req: Request, context: Context) => {
if (req.method !== "POST") return new Response("Method not allowed", { status: 405 });
try {
const { name, email, message } = await req.json();
if (!name ||!email ||!message) return new Response("Missing fields", { status: 400 });
// Mock email API
await fetch("https://api.emailservice.com/send", {
method: "POST",
headers: { "Authorization": `Bearer ${Netlify.env.get("EMAIL_API_KEY")}`, "Content-Type": "application/json" },
body: JSON.stringify({to: "test@example.com", subject: `Hello world`, text: `Hello ${name}` })
});
return Response.json({ success: true });
} catch {
return new Response("Server error", { status: 500 });
}
};
import { getStore } from "@netlify/blobs";
import type { Context } from "@netlify/functions";
import { v4 as uuid } from "uuid";
export default async (req: Request, context: Context) => {
// Accessing the request as `multipart/form-data`.
const form = await req.formData();
const file = form.get("file") as File;
// Generating a unique key for the entry.
const key = uuid();
const uploads = getStore("file-uploads");
await uploads.set(key, file, {
metadata: { country: context.geo.country.name }
});
return new Response("Submission saved");
};