getpkg/test/main.cpp
2025-05-26 13:31:56 +12:00

20 lines
392 B
C++

#include <iostream>
#include <httplib.h>
#include <nlohmann/json.hpp>
#include <libassert/assert.hpp>
int main() {
httplib::Client cli("https://ipinfo.io");
auto res = cli.Get("/ip");
ASSERT(res->status == 200, "Failed to get IP");
nlohmann::json j;
j["ip"] = res->body;
j["status"] = res->status;
std::cout << j.dump(4) << std::endl;
return 0;
}