-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (42 loc) · 1.15 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <string>
#include <algorithm>
#include "httpservice.h"
using namespace openrc;
using namespace std;
string _address = "0.0.0.0";
string _port = "10000";
string _root = "./";
int main(int argc, char* argv[])
{
HttpServiceArguments arguments;
if (argc == 4)
{
_address = argv[1];
_port = argv[2];
arguments.Push("root", argv[3]);
//std::cerr << "Usage: http_server <address> <port> <doc_root>\n";
//std::cerr << " For IPv4, try:\n";
//std::cerr << " receiver 0.0.0.0 80 .\n";
//std::cerr << " For IPv6, try:\n";
//std::cerr << " receiver 0::0 80 .\n";
//return 1;
}
arguments.Push("thread_pool_size", "4");
HttpService service(arguments);
cout << "Start HTTP Service: " << _address << ":" << _port << ", " << _root << endl;
service.Start(_address, _port);
bool bExit = false;
do
{
string command;
getline (std::cin, command);
transform(command.begin(), command.end(), command.begin(), ::tolower);
if (command == "stop" || command == "exit")
bExit = true;
}
while (!bExit);
service.Stop();
service.Join();
return 0;
}