forked from oulhafiane/HTTP-Web-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (43 loc) · 1.86 KB
/
main.cpp
File metadata and controls
49 lines (43 loc) · 1.86 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zoulhafi <zakariaa@oulhafiane.me> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/21 11:22:40 by zoulhafi #+# #+# */
/* Updated: 2022/05/25 14:15:31 by zoulhafi ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include "Config.hpp"
#include "Server.hpp"
int main(int argc, char **argv) {
if (argc > 2) {
std::cerr << "Usage: ./webserv [configuration file]" << std::endl;
return 1;
}
std::string path = "";
if (argc == 2)
path = std::string(argv[1]);
else
path = std::string("webserv.conf");
try {
Config conf(path);
/* Temporarely Printing Parsed Data
std::cout << "====Global====" << std::endl;
for (string_string_map::const_iterator it=conf.get_global_config().begin(); it!=conf.get_global_config().end(); ++it) {
std::cout << it->first << " => " << it->second << std::endl;
}
std::cout << "====Http====" << std::endl;
for (string_string_map::const_iterator it=conf.get_http_config().begin(); it!=conf.get_http_config().end(); ++it) {
std::cout << it->first << " => " << it->second << std::endl;
}
================ */
Server server(conf);
server.start();
} catch (std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}