main.cpp 487 B

123456789101112131415161718192021
  1. #include <iostream>
  2. #include <include/cinatra.hpp>
  3. using namespace cinatra;
  4. int main() {
  5. http_server server(std::thread::hardware_concurrency());
  6. bool r = server.listen("0.0.0.0", "8090");
  7. if (!r) {
  8. std::cout << "listen failed\n";
  9. return -1;
  10. }
  11. server.enable_timeout(false);
  12. server.set_http_handler<GET>("/plaintext", [](request& req, response& res) {
  13. res.set_status_and_content<status_type::ok,res_content_type::string>("Hello, World!");
  14. });
  15. server.run();
  16. return 0;
  17. }