Add the templates for npm

This commit is contained in:
2026-05-10 20:52:26 -05:00
parent e77b071af1
commit 0459b0a84e
57 changed files with 945 additions and 74 deletions

View File

@@ -0,0 +1,37 @@
class MyWebApp {
private fileServer;
private mountable;
private pages;
public MyWebApp()
{
this.fileServer = new FileServer(embeddir("/"), true, false);
this.mountable = new MountableServer((ctx)=>{
const page = this.pages.[ctx.Path];
if(TypeIsDefined(page)) return page(ctx);
return false;
});
this.mountable.Mount("/dist/",this.fileServer);
this.pages = {
.["/"] = Pages.Index,
.["/counter"] = Pages.Counter,
.["/about"] = Pages.About,
.["/echo"] = Pages.Echo
};
}
public Handle(ctx)
{
return this.mountable.Handle(ctx);
}
public Close()
{
this.mountable = null;
}
}
func WebAppMain(args)
{
return new MyWebApp();
}