From 9f7530aa40c4197a8c1979b37baab43ba2e6205f Mon Sep 17 00:00:00 2001 From: Marc Lasch Date: Tue, 11 Aug 2015 15:13:25 +0200 Subject: hello world test for mongoose --- .gitignore | 5 +++++ .gitmodules | 3 +++ Makefile | 21 +++++++++++++++++++++ mongoose | 1 + src/server.cpp | 34 ++++++++++++++++++++++++++++++++++ www/index.html | 10 ++++++++++ 6 files changed, 74 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Makefile create mode 160000 mongoose create mode 100644 src/server.cpp create mode 100644 www/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b97cea --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.project +.cproject +bin +*.o +*.swp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1d5002f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "mongoose"] + path = mongoose + url = https://github.com/cesanta/mongoose diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9c682b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +OBJ=src/server.o mongoose/mongoose.o +OUT=bin/server + +CFLAGS += -Wall -DNO_CGI -DNO_POPEN -DUSE_IPV6 +CXXFLAGS += -Wall -std=c++0x -Imongoose +#LDFLAGS += + +ifdef DEBUG +CFLAGS += -g -O0 +CXXFLAGS += -g -O0 +else +CFLAGS += -O3 +CXXFLAGS += -O3 +endif + +all: build + +build: $(OBJ) + $(CXX) $(CPPFLAGS) $(OBJ) -o $(OUT) $(LDFLAGS) +clean: + rm -rf $(OUT) $(OBJ) diff --git a/mongoose b/mongoose new file mode 160000 index 0000000..41b405d --- /dev/null +++ b/mongoose @@ -0,0 +1 @@ +Subproject commit 41b405d7bf6e620bf0a8e34e30f135a7e81d613d diff --git a/src/server.cpp b/src/server.cpp new file mode 100644 index 0000000..222e8ea --- /dev/null +++ b/src/server.cpp @@ -0,0 +1,34 @@ +#include +#include +#include "mongoose.h" + +using namespace std; + +int event_handler(struct mg_connection *conn, enum mg_event ev) { + switch (ev) { + case MG_AUTH: return MG_TRUE; + case MG_REQUEST: + if (conn->uri) { + cout<request_method<<" "<uri< + + + + + + +

Hello World!

+ + -- cgit v1.2.1