diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6bde5f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Use an official Ubuntu as a parent image +FROM ubuntu:latest + +# Set the working directory in the container to /app +WORKDIR /server + +# Install necessary packages, including CMake, a C++ compiler, and wget +RUN apt-get update && \ + apt-get install -y cmake g++ make wget && \ + apt-get clean; + +# Copy the current directory contents into the container at /app +COPY . /server + +# Download Crow library +RUN wget https://github.com/CrowCpp/Crow/archive/refs/heads/master.zip -O crow.zip && \ + unzip crow.zip && \ + mv Crow-master/crow/include/crow.h /usr/local/include/ + +# Make the build directory +RUN mkdir -p build && cd build + +# Run CMake to configure the build +RUN cmake .. + +# Build the project +RUN make + +# Expose port 8888 for the web server +EXPOSE 8888 + +# Command to run the executable +CMD ["./douwco_web"] diff --git a/include/server.hpp b/include/server.hpp index c7d6a91..bea82a9 100644 --- a/include/server.hpp +++ b/include/server.hpp @@ -6,16 +6,17 @@ namespace Douwco { class Server { + + private: + static constexpr int port = 8888; + crow::SimpleApp crowApp; + public: Server() = default; ~Server() = default; void setup(); void start(); - - private: - static constexpr int port = 8080; - crow::SimpleApp crowApp; }; } diff --git a/src/server.cpp b/src/server.cpp index 499d9ae..eb401a7 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2,11 +2,18 @@ #include "server.hpp" -void Douwco::Server::setup() { - CROW_ROUTE(crowApp, "/")([](){ - std::string page = crow::mustache::load("home.html").render_string(); - return page; +#define CREATE_ROUTE(route_path, html_path) \ + CROW_ROUTE(this->crowApp, route_path) \ + ([]() { \ + std::string page = crow::mustache::load(html_path).render_string(); \ + return page; \ }); + +void Douwco::Server::setup() { + CREATE_ROUTE("/", "home.html"); + CREATE_ROUTE("/about_me", "about_me.html"); + CREATE_ROUTE("/about_douwco", "about_douwco.html"); + CREATE_ROUTE("/games", "games.html"); } void Douwco::Server::start() { @@ -15,4 +22,4 @@ void Douwco::Server::start() { .multithreaded() // .ssl_file("dev_cert/certificate.pem","dev_cert/private.key") .run(); -} +} \ No newline at end of file diff --git a/templates/about_douwco.html b/templates/about_douwco.html new file mode 100644 index 0000000..db1411c --- /dev/null +++ b/templates/about_douwco.html @@ -0,0 +1,28 @@ + + +
+ + + + + +
+
+
+
+
+
+