fastro init
command will generate folders and files like this.
webapp
├── Dockerfile
├── main.ts
├── middleware
│ └── support.ts
├── public
│ ├── favicon.ico
│ └── index.html
└── services
├── hello.controller.ts
└── hello.template.html
3 directories, 7 files
You can render html template and pass dynamic value on it.
hello.template.html
in services
folder
<html>
<head>
<title>${greeting} ${name}</title>
</head>
<body>
${greeting} ${name}
</body>
</html>
You can change hello
name with other.
Open hello.controller.ts
handler.
Uncomment request.view
and comment request.send
.
import type { Request } from "https://raw.fastro.dev/master/mod.ts";
export const handler = (request: Request) => {
request.view("hello.template.html", { greeting: "Hello", name: "World" });
// request.send("hello");
};
Open url
http://localhost:3000/hello
Now you see the greeting and name on the browser.