38 lines
765 B
C++
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;
|
|
} |