From 8fc7140e064227aa14baa9b992641c54a917cbfb Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 4 Jul 2013 22:46:25 -0400 Subject: [PATCH] added port no. and base dir arguments to simplesvr. --- example/simplesvr.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/example/simplesvr.cc b/example/simplesvr.cc index 977b3d3..dd44f08 100644 --- a/example/simplesvr.cc +++ b/example/simplesvr.cc @@ -58,6 +58,11 @@ string log(const Request& req, const Response& res) int main(int argc, const char** argv) { + if (argc > 1 && string("--help") == argv[1]) { + cout << "usage: simplesvr [PORT] [DIR]" << endl; + return 1; + } + Server svr; svr.set_error_handler([](const Request& req, Response& res) { @@ -71,15 +76,20 @@ int main(int argc, const char** argv) cout << log(req, res); }); - int port = 8080; + auto port = 80; if (argc > 1) { port = atoi(argv[1]); } + auto base_dir = "./"; if (argc > 2) { - svr.set_base_dir(argv[2]); + base_dir = argv[2]; } + svr.set_base_dir(base_dir); + + cout << "The server started at port " << port << "..."; + svr.listen("localhost", port); return 0;