diff --git a/includes/webserv.hpp b/includes/webserv.hpp index 2874854..833fd32 100644 --- a/includes/webserv.hpp +++ b/includes/webserv.hpp @@ -10,7 +10,6 @@ #include #include #include - #include #include #include @@ -56,7 +55,6 @@ string read_file(string path); #include "Nodes.hpp" #include "Token.hpp" #include "Parser.hpp" - #include "Route.hpp" #include "Socket.hpp" #include "Server.hpp" diff --git a/public/documents/test1 b/public/documents/test1 index e69de29..66cd14e 100644 --- a/public/documents/test1 +++ b/public/documents/test1 @@ -0,0 +1 @@ +===||This is a test file||=== \ No newline at end of file diff --git a/public/documents/test2 b/public/documents/test2 index e69de29..9d80a16 100644 --- a/public/documents/test2 +++ b/public/documents/test2 @@ -0,0 +1 @@ +===||This is a test2 file||=== \ No newline at end of file diff --git a/public/images/a_file b/public/images/a_file deleted file mode 100644 index 458a936..0000000 --- a/public/images/a_file +++ /dev/null @@ -1,2 +0,0 @@ -jdkslaj\njkdsa;jfd\njdkaj;fjd -jdkslaj\njkdsa;jfd\njdkaj;fjd diff --git a/public/testsite/basique.html b/public/testsite/basique.html index 111a447..9336073 100644 --- a/public/testsite/basique.html +++ b/public/testsite/basique.html @@ -19,7 +19,7 @@ document.querySelector('body').innerHTML = ''; const button2 = document.querySelector('button.second'); button2.addEventListener('click', function () { - document.querySelector('body').innerHTML = ''; + document.querySelector('body').innerHTML = ''; }); }); diff --git a/public/testsite/basique.php b/public/testsite/basique.php index 494265e..4a55228 100644 --- a/public/testsite/basique.php +++ b/public/testsite/basique.php @@ -3,6 +3,7 @@ PHP Test - PHP page

'; ?> + PHP page

'; ?>
+

Copyright © NicoWalid

\ No newline at end of file diff --git a/public/images/monkey.gif b/public/testsite/monkey.gif similarity index 100% rename from public/images/monkey.gif rename to public/testsite/monkey.gif diff --git a/srcs/webserv.cpp b/srcs/webserv.cpp index dacfbe3..8c5c235 100644 --- a/srcs/webserv.cpp +++ b/srcs/webserv.cpp @@ -6,16 +6,21 @@ int Socket::_min_fd = INT_MAX; int Socket::_amount = 0; int main(int ac, char **av) { - - if (ac < 2) { - cout << "Usage:\n"; - cout << "./webserv CONF.json\n"; - cout << "WARNING: You must use a correct json syntax and a correct " - "server configuration or don't expect it to work correctly."; - } else if (ac == 2) { + if (ac <= 2) { + std::string config = "default.json"; + if (ac == 2){ + std::ifstream file(av[1]); + if (file.good()) + config = av[1]; + else { + std::cout << "Error: " << av[1] << " is not a valid file" << std::endl; + return EXIT_FAILURE; + } + config = av[1]; + } cout << "Parsing configuration file from JSON conf file.\n"; cout << "You must be sure the syntax is correct\n"; - JSONParser parser(av[1]); + JSONParser parser(config); JSONNode *conf = parser.parse(); cout << "Initialization of server...\n"; Env env(conf); @@ -27,12 +32,14 @@ int main(int ac, char **av) { env.set_fds(); cout << "|===||===| Waiting some HTTP request... |===||===|\n"; int activity = select(Socket::_max_fd + Socket::_amount, - &(Socket::_readfds), NULL, NULL, NULL); + &(Socket::_readfds), NULL, NULL, NULL); if ((activity < 0) && (errno != EINTR)) cout << "Select: " << strerror(errno) << "\n"; cout << "==> Handle requests and answers:\n"; env.refresh(); } } + else + cout << "Usage:\n./webserv CONF.json\n"; return (0); }