deleted more stringstrem
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
This commit is contained in:
1 parent
e0f5ca7266
commit
e194a44bf9
3 files changed
+20
-24
No files matched your search
@@ -2,7 +2,6 @@
|
||||
#ifdef __linux__
|
||||
#include <sys/sysinfo.h>
|
||||
#endif // __linux__
|
||||
#include <sstream>
|
||||
#include <types.hpp>
|
||||
|
||||
namespace api
|
||||
@@ -15,15 +14,14 @@ namespace api
|
||||
struct sysinfo x;
|
||||
if (sysinfo(&x) == 0)
|
||||
{
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"uptime":{"hour":")"
|
||||
<< static_cast<unsigned long long>(x.uptime) / 3600ULL
|
||||
<< R"(","minute":")"
|
||||
<< static_cast<unsigned long long>(x.uptime) / 60ULL % 60ULL
|
||||
<< R"(","second":")"
|
||||
<< static_cast<unsigned long long>(x.uptime) % 60ULL
|
||||
<< R"("}})";
|
||||
response.set_content(responsedata.str(), JSON_TYPE);
|
||||
std::string responsedata(R"({"uptime":{"hour":")"
|
||||
+ std::to_string(static_cast<unsigned long long>(x.uptime) / 3600ULL)
|
||||
+ R"(","minute":")"
|
||||
+ std::to_string(static_cast<unsigned long long>(x.uptime) / 60ULL % 60ULL)
|
||||
+ R"(","second":")"
|
||||
+ std::to_string(static_cast<unsigned long long>(x.uptime) % 60ULL)
|
||||
+ R"("}})");
|
||||
response.set_content(responsedata, JSON_TYPE);
|
||||
return;
|
||||
}
|
||||
response.set_content(R"({"error":"unknown"})", JSON_TYPE);
|
||||
|
||||
Reference in new issue
Block a user