Files
hate/Main.cpp
2025-11-22 16:25:58 +01:00

48 lines
1.1 KiB
C++

#include <iostream>
#include <string>
#include <sstream>
#include "Windows.h"
#include "Router.h"
#include "Terminal.h"
#include "Resource.h"
int main()
{
SetConsoleMode((HANDLE)(size_t)STD_OUTPUT_HANDLE, ENABLE_VIRTUAL_TERMINAL_PROCESSING);
std::string req_raw =
"GET /url/path HTTP/1.1\r\n"
"Host: example.com\r\n"
"Host: www.example.com\r\n"
"User - Agent : Mozilla / 5.0\r\n"
"Accept : text / html, application / xhtml + xml, application / xml; q = 0.9, image / avif, image / webp, */*;q=0.8\r\n"
"Accept-Language: en-GB,en;q=0.5\r\n"
"Accept-Encoding: gzip, deflate, br\r\n"
"Connection: keep-alive\r\n"
"\r\n";
std::stringstream req(req_raw);
Router router;
router.on_get("/", [&](Request& req, Response& res, Next next) {
Resource src(INDEX, HTML_FILE);
res.header("Content-Type", "text/html");
res.send(src.data(), src.size());
});
router.on_get("/url/path", [&](Request& req, Response& res, Next next) {
res.send("Hello, World!");
});
std::stringstream res;
router.handle(req, res);
std::cout << CYAN << res.str() << RESET << std::endl;
router.listen(8080);
}