Crafter.CppDOM/examples/FetchExample/main.cpp

16 lines
501 B
C++
Raw Permalink Normal View History

2025-11-11 00:21:11 +01:00
import Crafter.CppDOM;
import std;
2025-11-14 18:40:13 +01:00
using namespace Crafter;
2025-11-11 00:21:11 +01:00
using namespace Crafter::CppDOMBindings;
2025-11-14 18:40:13 +01:00
HtmlElementPtr body("body", "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
2025-11-11 00:21:11 +01:00
int main(){
2025-11-14 18:40:13 +01:00
Fetch("https://httpbin.org/get", [](std::string result){
2025-11-11 00:21:11 +01:00
if (!result.empty()) {
2025-11-14 18:40:13 +01:00
body.SetInnerHTML("<h1>Fetch Example</h1><p>Response: " + result + "</p>");
2025-11-11 00:21:11 +01:00
} else {
2025-11-14 18:40:13 +01:00
body.SetInnerHTML("<h1>Fetch Example</h1><p>Failed to fetch data</p>");
2025-11-11 00:21:11 +01:00
}
});
}