26 lines
807 B
C++
26 lines
807 B
C++
#pragma once
|
|
|
|
#include <drogon/HttpController.h>
|
|
|
|
using namespace drogon;
|
|
|
|
class Scratchpad : public drogon::HttpController<Scratchpad>
|
|
{
|
|
public:
|
|
METHOD_LIST_BEGIN
|
|
// POST /scratchpad/run -> Protected (API Key required)
|
|
METHOD_ADD(Scratchpad::runCode, "/run", Post);
|
|
|
|
// GET /scratchpad/status -> Public
|
|
METHOD_ADD(Scratchpad::status, "/status", Get);
|
|
METHOD_LIST_END
|
|
|
|
void runCode(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
|
|
void status(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
|
|
|
|
private:
|
|
// Helper to compile and execute C++ code
|
|
std::string compileAndRun(const std::string& code);
|
|
const std::string API_KEY = "SixBabiesShittingPoutine!!"; // Protected access
|
|
};
|