import type { APIRoute } from "astro"

export const POST: APIRoute = async ({ request, redirect }) => {
    // Get Form Data
    const formData = await request.formData()
    const web_search = formData.get("websearch")?.toString()

    // If the user presses "Enter" on a blank search, return to home
    if (!web_search) {
        return redirect("/")
    }

    // Go to search term
    return redirect("/web?=" + web_search)
}