Select Git revision
main.cpp

Simon Consoir authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
main.cpp 747 B
#include "crow.h"
#include <cstdlib>
#include <sstream>
#include <fstream>
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/execute").methods(crow::HTTPMethod::Post)
([](const crow::request& req, crow::response& res) {
std::string command = req.body;
std::string full_command = command + " 2>&1 | tee output.txt";
int result = std::system(full_command.c_str());
// Read the output from the file
std::ifstream output_file("output.txt");
std::stringstream output_buffer;
output_buffer << output_file.rdbuf();
std::string output = output_buffer.str();
res.write("Done");
res.end();
});
app.port(10001).multithreaded().run();
return 0;
}