first commit

This commit is contained in:
adrian
2025-10-11 17:15:21 +02:00
commit f3671429ee
6 changed files with 201 additions and 0 deletions

31
backend.cpp Normal file
View File

@ -0,0 +1,31 @@
#include "crow.h"
#include <string>
#include <iostream>
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
auto page = crow::mustache::load_text("index.html");
return page;
});
CROW_ROUTE(app, "/button").methods("POST"_method)([](const crow::request& req) {
auto x = crow::json::load(req.body);
if (!x) {
return crow::response(400, "invalid JSON");
}
std::string name = x["name"].s();
name.erase(std::remove_if(name.begin(), name.end(), ::isspace), name.end());
std::cout << name << std::endl;
return crow::response(200, name);
});
app.port(18080).multithreaded().run();
}