fileserver.h 518 B

123456789101112131415161718192021222324252627282930
  1. #ifndef __FILESERVER_H__
  2. #define __FILESERVER_H__
  3. #include <httplib.h>
  4. #include <stdint.h>
  5. #include <thread>
  6. class FileServer
  7. {
  8. public:
  9. explicit FileServer();
  10. ~FileServer();
  11. std::string addr() const;
  12. uint16_t port() const;
  13. bool isRunning() const;
  14. void run(const char *addr, unsigned short port);
  15. void start();
  16. void stop();
  17. private:
  18. std::string m_addr;
  19. uint16_t m_port;
  20. bool m_isRunning;
  21. std::thread m_thread;
  22. httplib::Server m_server;
  23. };
  24. #endif // FILESERVER_H