mirror of
https://onedev.site.tesses.net/tesses-framework/tessesframework-webapp
synced 2026-02-08 08:25:46 +00:00
First Commit
This commit is contained in:
23
examples/printargs.cpp
Normal file
23
examples/printargs.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user