-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebserver.cpp
More file actions
56 lines (50 loc) · 992 Bytes
/
Webserver.cpp
File metadata and controls
56 lines (50 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @file Webserver.cpp
* @author Maxwell Ding (jding263)
* @brief Webserver class that works as the framework of the web server
* @date 2023-11-28
*
* @copyright Copyright (c) 2023
*
*/
#include "Webserver.h"
/**
* @brief Construct a new Webserver:: Webserver object
*
*/
Webserver::Webserver()
{
router.enroute(app);
std::cout << "Web Server created" << std::endl;
}
/**
* @brief Destroy the Webserver:: Webserver object
*
*/
Webserver::~Webserver()
{
std::cout << "Web Server destroyed" << std::endl;
}
/**
* @brief run the webserver on the specified port
*
* @param port
*/
void Webserver::run(int port)
{
std::cout << "Web Server running on port " << port << std::endl;
try {
app.port(port).multithreaded().run();
}
catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
}
/**
* @brief stop the webserver
*
*/
void Webserver::stop()
{
std::cout << "Web Server stopped" << std::endl;
}