From 8f3abd66d3d0a70c9dbd790e430bf8690f58c49f Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 18 May 2024 16:29:46 +0500 Subject: feat: web project --- CMakeLists.txt | 24 ++++++++++++++++++++++++ web/src/main.cpp | 10 ++++++++++ 2 files changed, 34 insertions(+) create mode 100644 web/src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fef134..2bd6745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_definitions(-DUSE_TLS=1) file(GLOB_RECURSE BOT_SRC_FILES "bot/src/*.cpp" "bot/src/*.h" "bot/src/*.hpp") +file(GLOB_RECURSE WEB_SRC_FILES "web/src/*.cpp" "web/src/*.h" "web/src/*.hpp") option(BUILD_BOT "Build the bot" ON) +option(BUILD_WEB "Build the web application" ON) if (BUILD_BOT) add_executable(Bot) @@ -66,3 +68,25 @@ if (BUILD_BOT) target_link_libraries(Bot PRIVATE ixwebsocket::ixwebsocket pqxx nlohmann_json::nlohmann_json cpr::cpr) endif() + +if (BUILD_WEB) + add_executable(Web) + + set_target_properties( + Web PROPERTIES + DESCRIPTION ${PROJECT_DESCRIPTION} + OUTPUT_NAME "redpilledweb" + ) + + target_sources(Web PRIVATE ${WEB_SRC_FILES}) + + # web framework + FetchContent_Declare( + crow + GIT_REPOSITORY https://github.com/CrowCpp/Crow + GIT_TAG v1.1.0 + ) + FetchContent_MakeAvailable(crow) + + target_include_directories(Web PRIVATE ${crow_SOURCE_DIR}/include) +endif() diff --git a/web/src/main.cpp b/web/src/main.cpp new file mode 100644 index 0000000..248328f --- /dev/null +++ b/web/src/main.cpp @@ -0,0 +1,10 @@ +#include "crow/app.h" + +int main(int argc, char *argv[]) { + crow::SimpleApp app; + + CROW_ROUTE(app, "/")([]() { return "hi"; }); + + app.multithreaded().port(18083).run(); + return 0; +} -- cgit v1.2.3