Files
tessesframework-webapp/examples/printargs.cpp
2025-10-14 23:17:27 -05:00

23 lines
672 B
C++

#include "TF_WebApp.hpp"
using namespace Tesses::Framework::Http;
using namespace Tesses::Framework;
TF_WebApp(MyApp,nullptr)
std::shared_ptr<IHttpServer> MyApp(std::vector<std::string>& args)
{
TF_WebAppSetTitle("Print Args");
return std::make_shared<CallbackServer>([&args](ServerContext& ctx)->bool {
if(ctx.path == "/")
{
std::string text = "<h1>Hello, world</h1><ul>";
for(auto item : args)
text += "<li>" + HttpUtils::HtmlEncode(item) + "</li>";
text += "</ul>";
ctx.WithMimeType("text/html").SendText(text);
return true;
}
return false;
});
}