The brief I gave myself was deliberately tiny. A single HTTP endpoint that returns `Hello, World!`, built in C++, deployed somewhere real, with the whole thing reproducible from a fresh checkout. The point was not to ship a product.
For the HTTP layer I picked Crow, a header-only framework with a Flask-shaped API. Header-only matters here because it keeps the build simple
The whole server is twelve lines:
#include <crow.h>
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/")([]{
return "Hello, World!";
});
app.port(8080).multithreaded().run();
return 0;
}
That is the entire C++ surface area of the project. A simple app, one route, a lambda that returns a string, and multithreaded().run() to actually serve requests. Bear in mind that CROW_ROUTE is a macro doing real work - it registers the handler at compile time - but from the outside it reads almost exactly like the Python equivalent, which is the point.
The build sits in a two-stage Dockerfile. The first stage is a Debian image with build-essential, cmake, and libasio-dev, which compiles a release binary. The second stage is a slim Debian image that contains only the compiled binary and `ca-certificates`.
For hosting Claude stubbornly insisted I go with AWS Lightsail's Container Service on the Nano tier — about seven dollars a month, with a built-in container registry so I do not need to wire up ECR or IAM roles for image pushes. Terraform provisions the service; a Makefile orchestrates the three steps of a deploy: terraform apply to ensure the service exists, aws lightsail push-container-image to upload a freshly built image, and a second terraform apply to roll out the new version. make deploy runs the lot.
Claude suggested that next, I should like to add a second route that does something genuinely C++-shaped — perhaps a small numerical endpoint, or something that exercises a library you would not casually reach for in Python. However, I've achieved what I wanted.

Comments
Post a Comment