From 489d2bb344226d4405d52b9e1fbd4cfd80477f66 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Mon, 23 Jan 2023 14:32:26 +0100 Subject: [PATCH] feat: add example --- example/main.cpp | 15 +++++++++++++++ example/makefile | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 example/main.cpp create mode 100644 example/makefile diff --git a/example/main.cpp b/example/main.cpp new file mode 100644 index 0000000..1960531 --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,15 @@ +#include +using namespace httpserver; +class hello_world_resource : public http_resource { +public: + std::shared_ptr render(const http_request&) { + return std::shared_ptr(new string_response("Hello, World!")); + } +}; +int main(int argc, char** argv) { + webserver ws = create_webserver(8080); + hello_world_resource hwr; + ws.register_resource("/hello", &hwr); + ws.start(true); + return 0; +} diff --git a/example/makefile b/example/makefile new file mode 100644 index 0000000..6e57144 --- /dev/null +++ b/example/makefile @@ -0,0 +1,20 @@ +#target: dependency_1 dependency_2 dependency_3 ... +# command +# +RM = /bin/rm -f +OBJ = main.o +EXE = main +CC = /usr/bin/g++ +CXXFLAGS = -Wall +LDFLAGS = -L/usr/local/lib -lhttpserver +# +all: $(EXE) +# +$(EXE): $(OBJ) + $(CC) $(CXXFLAGS) $(LDFLAGS) $(OBJ) -o $(EXE) +# +main.o: main.cpp + $(CC) -c main.cpp -o main.o +# +clean: + $(RM) $(OBJ) $(EXE) *~