This commit is contained in:
blankie 2023-04-03 22:10:08 +07:00
parent 6ceea16739
commit 7f1cde5579
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
5 changed files with 34 additions and 3 deletions

View File

@ -24,7 +24,7 @@ add_link_options(${FLAGS})
add_executable(${PROJECT_NAME} main.cpp misc.cpp config.cpp servehelper.cpp blankie/serializer.cpp blankie/escape.cpp
routes/home.cpp)
routes/home.cpp routes/css.cpp)
set_target_properties(${PROJECT_NAME}
PROPERTIES
CXX_STANDARD 20

View File

@ -3,7 +3,7 @@
#include <nlohmann/json.hpp>
#include "config.h"
#include "routes/home.h"
#include "routes/routes.h"
int main(int argc, char** argv) {
if (argc != 2) {
@ -23,6 +23,7 @@ int main(int argc, char** argv) {
server.Get("/", [&](const httplib::Request& req, httplib::Response& res) {
home_route(req, res, config);
});
server.Get("/style.css", css_route);
if (config.bind_port != 0) {
if (!server.bind_to_port(config.bind_host, config.bind_port)) {

29
routes/css.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "routes.h"
void css_route(const httplib::Request& req, httplib::Response& res) {
res.set_content(R"EOF(
:root {
--background-color: black;
--text-color: white;
--accent-color: #962AC3;
--dark-accent-color: #7D3F7D;
--bright-accent-color: #DE6DE6;
}
body {
background-color: var(--background-color);
color: var(--text-color);
}
a {
color: var(--accent-color);
text-decoration: none;
}
a:hover {
color: var(--bright-accent-color);
text-decoration: underline;
}
)EOF", "text/css");
}

View File

@ -1,4 +1,4 @@
#include "home.h"
#include "routes.h"
#include "../servehelper.h"
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config) {

View File

@ -5,3 +5,4 @@
struct Config; // forward declaration from config.h
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config);
void css_route(const httplib::Request& req, httplib::Response& res);