mirror of
https://onedev.site.tesses.net/tesses-framework/tessesframework-webapp
synced 2026-02-08 08:25:46 +00:00
23 lines
672 B
C++
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;
|
|
});
|
|
} |