Files
dropshell-build/tests/cprdemo/src/main.cpp
Your Name 11e3d20a4c
All checks were successful
dropshell-build multiarch / build (linux/amd64) (push) Successful in 18s
dropshell-build multiarch / build (linux/arm64) (push) Successful in 25s
dropshell-build multiarch / create-manifest (push) Successful in 13s
config: Update 2 files
2025-06-29 15:56:23 +12:00

38 lines
765 B
C++

#include <iostream>
#include <nlohmann/json.hpp>
#ifdef CPR_HEADERS_MISSING
#include "cpr_stubs.hpp"
#else
#include <cpr/cpr.h>
#endif
#include "version.hpp"
#include "assert.hpp"
void crashy() {
ASSERT(false, "SUCCESS!");
}
int main() {
std::cout << "cprdemo version: " << cprdemo::VERSION << std::endl;
std::cout << std::endl;
std::cout << "Retrieving IP address using CPR..." << std::endl;
// Use CPR to make HTTP GET request
cpr::Response r = cpr::Get(cpr::Url{"https://ipinfo.io/ip"});
ASSERT(r.status_code == 200, "Failed to get IP");
nlohmann::json j;
j["ip"] = r.text;
j["status"] = r.status_code;
std::cout << j.dump(4) << std::endl;
std::cout << "Done" << std::endl;
crashy();
return 0;
}