main.cpp 822 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <iostream>
  2. #include "tunnelconstructor.h"
  3. #include <fstream>
  4. #include "http/httpserver.h"
  5. #include "htmldata.h"
  6. void usage(char* argv0)
  7. {
  8. std::cout << "Usage:" << std::endl;
  9. std::cout << argv0 << " <bind address> <bind port>" << std::endl;
  10. }
  11. int main(int argc, char* argv[])
  12. {
  13. if (argc < 3)
  14. {
  15. usage(argv[0]);
  16. return 0;
  17. }
  18. const std::string address (argv[1]);
  19. const uint16_t port (std::stoi(argv[2]));
  20. std::cout << "Address: http://" << address << ":" << port << std::endl;
  21. crow::App<crow::UTF8> app;
  22. app.loglevel(crow::LogLevel::Critical);
  23. HttpServer server(address, port);
  24. try {
  25. server.run();
  26. } catch (std::exception& e) {
  27. std::cerr << "Server failure: " << e.what() << std::endl;
  28. return 1;
  29. }
  30. return 0;
  31. }