Ooui-tws-port/Example/Program.cs

25 lines
600 B
C#

using Tesses.WebServer;
using Ooui;
UI ui=new UI();
ui.Verbose = false;
Button btn = new Button(){Text = "Click Me"};
int i =0;
btn.Click += (sender,e)=>{
btn.Text = $"Clicked {++i} time(s)";
};
ui.Publish("/",btn);
ui.Publish("/query",(ctx)=>{
Ooui.List list=new List();
foreach(var item in ctx.QueryParams)
{
foreach(var v in item.Value)
{
Ooui.ListItem listItem=new ListItem();
listItem.Text = $"{item.Key}: {v}";
list.AppendChild(listItem);
}
}
return list;
});
ui.StartServer(45252);