Template
1
0

Added processFormData and reorganised the files

This commit is contained in:
2025-07-07 03:11:41 +03:00
parent 4962bb5a2d
commit 481b4b410a
10 changed files with 114 additions and 15 deletions

16
src/Base/Entry.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include "../Main.hpp"
#include <exception>
#include <iostream>
// Entry point a.k.a "main.cpp"
// You do not want to program here 99% of the time
int main(int argc, char *argv[]) {
try {
asio::io_context context;
Webserver server(context);
context.run();
} catch (std::exception &e) {
std::cerr << e.what() << "\n";
}
return 0;
}

27
src/Base/Webserver.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "../Main.hpp"
#include <iostream>
#include <ostream>
// Webserver is defined at main.hpp, you probably do not want to code here
Webserver::Webserver(asio::io_context &context)
: io(context),
accept(context,
asio::ip::tcp::endpoint(asio::ip::make_address(IP), PORT)) {
std::cout << "Server is up!\n";
initResponses();
std::cout << "Path responses are set up!" << std::endl;
begin();
}
void Webserver::begin() {
HTTPrequest::HTTPrequest_ptr newconn = HTTPrequest::create(io);
accept.async_accept(newconn->socket(),
[this, newconn](const asio::error_code &err) {
if (!err) {
newconn->start();
}
begin();
});
}