mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Added 'hello' example.
This commit is contained in:
parent
be2a1fdb9d
commit
181d642238
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
tags
|
tags
|
||||||
sample
|
sample
|
||||||
|
hello
|
||||||
|
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
@ -3,15 +3,20 @@ USE_CLANG = 1
|
|||||||
|
|
||||||
ifdef USE_CLANG
|
ifdef USE_CLANG
|
||||||
CC = clang++
|
CC = clang++
|
||||||
CFLAGS = -std=c++0x -stdlib=libc++
|
CFLAGS = -std=c++0x -stdlib=libc++ -g
|
||||||
else
|
else
|
||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS = -std=c++11
|
CFLAGS = -std=c++11 -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
all: sample hello
|
||||||
|
|
||||||
sample : sample.cc ../httpsvrkit.h
|
sample : sample.cc ../httpsvrkit.h
|
||||||
$(CC) -o sample $(CFLAGS) -I.. sample.cc
|
$(CC) -o sample $(CFLAGS) -I.. sample.cc
|
||||||
|
|
||||||
|
hello : hello.cc ../httpsvrkit.h
|
||||||
|
$(CC) -o hello $(CFLAGS) -I.. hello.cc
|
||||||
|
|
||||||
.PHONY : test
|
.PHONY : test
|
||||||
test: sample
|
test: sample
|
||||||
./sample
|
./sample
|
||||||
|
27
example/hello.cc
Normal file
27
example/hello.cc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// hello.cc
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012 Yuji Hirose. All rights reserved.
|
||||||
|
// The Boost Software License 1.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <httpsvrkit.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
HTTP_SERVER("localhost", 1234) {
|
||||||
|
|
||||||
|
// const httpsvrkit::Request& req
|
||||||
|
// httpsvrkit::Response& res
|
||||||
|
|
||||||
|
GET("/hello", {
|
||||||
|
res.set_content("world");
|
||||||
|
});
|
||||||
|
|
||||||
|
GET("/url", {
|
||||||
|
res.set_content(req.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: et ts=4 sw=4 cin cino={1s ff=unix
|
Loading…
x
Reference in New Issue
Block a user