Created
July 29, 2023 18:50
-
-
Save kenny-io/45c92d7b6c67211bb31edebd8dafdd18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { builder } from "@netlify/functions"; | |
const myHandler = async (event, context) => { | |
const segments = event.path.split('/'); | |
const name = segments[segments.length - 1]; | |
console.log(name); | |
const greeting = name ? `Hello ${name}` : 'Hello World'; | |
return { | |
statusCode: 200, | |
headers: { | |
"Content-Type": "text/html", | |
}, | |
body: ` | |
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<h1>${greeting}</h1> | |
</body> | |
</html> | |
`, | |
}; | |
}; | |
const handler = builder(myHandler); | |
export { handler }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment