blob: b079707f08263dc486973dd16005591445c953fa (
plain)
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
|
#include "config.h"
#include "http.h"
#include <exception>
#include <iostream>
#include <string>
using namespace std::string_literals;
void usage()
{
std::cout << "usage: webserver [-c <configuration-filename>]" << std::endl;
}
int main(int argc, char* argv[])
{
std::string config_filename;
if (!(argc == 1 || argc == 3)) {
usage();
return 1;
}
if (argc == 3) {
if (argv[1] != "-c"s) {
usage();
return 1;
}
config_filename = argv[2];
}
try {
Config config{config_filename};
return http_server(argc, argv);
} catch (const std::exception& ex) {
std::cout << "Error: " << ex.what() << std::endl;
return 1;
}
}
|