commit f3671429ee5e1bd01de858c3bec2e34d5320c04a Author: adrian Date: Sat Oct 11 17:15:21 2025 +0200 first commit diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e86253b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "enter program name, for example ${workspaceFolder}/a.out", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e6ed381 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +CXX = g++ +CXXFLAGS = -std=c++17 -Wall -pthread +TARGET = backend +SRCS = backend.cpp + +all: $(TARGET) + ./$(TARGET) + +$(TARGET): $(SRCS) + $(CXX) $(CXXFLAGS) -o $(TARGET) $(SRCS) + +clean: + rm -f $(TARGET) + +.PHONY: all clean \ No newline at end of file diff --git a/backend b/backend new file mode 100755 index 0000000..7674c2a Binary files /dev/null and b/backend differ diff --git a/backend.cpp b/backend.cpp new file mode 100644 index 0000000..8982afb --- /dev/null +++ b/backend.cpp @@ -0,0 +1,31 @@ +#include "crow.h" +#include +#include + + +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(); +} + + + + diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..bad9efd --- /dev/null +++ b/compose.yml @@ -0,0 +1,33 @@ +version: "3.8" + +services: + db: + image: postgres:latest + container_name: postgres_latest + restart: unless-stopped + environment: + POSTGRES_USER: duck + POSTGRES_PASSWORD: duckpass + POSTGRES_DB: duckdb + volumes: + - db_data:/var/lib/postgresql/data + ports: + - "5432:5432" + + pgadmin: + image: dpage/pgadmin4:latest + container_name: pgadmin_latest + restart: unless-stopped + environment: + PGADMIN_DEFAULT_EMAIL: admin@example.com + PGADMIN_DEFAULT_PASSWORD: adminpass + volumes: + - pgadmin_data:/var/lib/pgadmin + ports: + - "8080:80" + depends_on: + - db + +volumes: + db_data: + pgadmin_data: diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..9157ffa --- /dev/null +++ b/templates/index.html @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + javascript test + + +
+ + + +
+
+
+
+ +
+ +
+ + \ No newline at end of file