Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Created July 29, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenny-io/45c92d7b6c67211bb31edebd8dafdd18 to your computer and use it in GitHub Desktop.
Save kenny-io/45c92d7b6c67211bb31edebd8dafdd18 to your computer and use it in GitHub Desktop.
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