diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 25fb548..bb475bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,12 +18,21 @@ int main(int argc, char** argv) HttpResponse response; response.add_header("Server", "cfws"); - if (request.header("Accept-Language").find("zh") == std::string::npos) { - response.set_status_code(HttpStatusCode::Forbidden); - response.set_content("Please set your language to Chinese to access this page."); - } else { + if (request.uri() == "/") { response.set_status_code(HttpStatusCode::OK); - response.set_content("Welcome to the page."); + response.add_header("Content-Type", "text/html"); + response.set_content("<h1>Welcome to the web server!</h1><a href=\"/language\">Click here!</a>"); + } else if (request.uri() == "/language") { + if (request.header("Accept-Language").find("zh") == std::string::npos) { + response.set_status_code(HttpStatusCode::Forbidden); + response.set_content("Please set your language to Chinese to access this page."); + } else { + response.set_status_code(HttpStatusCode::OK); + response.set_content("Welcome to the page."); + } + } else { + response.set_status_code(HttpStatusCode::NotFound); + response.set_content("Page not found!"); } client.send(response); |