import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
import { html } from "https://esm.town/v/stevekrouse/html";
import { email as email2 } from "https://esm.town/v/std/email?v=9";
let { formDataEx } = await import("https://esm.town/v/stevekrouse/formDataEx");
export let form = async (req: Request) => {
if (req.method === "POST") {
let email = (await req.formData()).get("email") as string;
formDataEx = formDataEx ?? [];
formDataEx.push(email);
await email2({ text: email, subject: "New Submission!" });
return html(`Thanks ${email}!`);
}
return html(`
<form action="${thisWebURL()}" method="post">
Email <input name="email" /> <button>Submit</button>
</form>`);
};