snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 7f2be13079c33db115ccd71cfc363fee9ef127ed
parent 00079323ccad162d55c0b1f7d25eddf3ea4c1e45
Author: default <nobody@localhost>
Date:   Thu,  2 Jan 2025 07:27:48 +0100

Serve BASE_URL/style.css.

I thought I was already doing this 🤦(not that it really matters much).

Diffstat:
Mhttpd.c | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/httpd.c b/httpd.c @@ -275,6 +275,19 @@ int server_get_handler(xs_dict *req, const char *q_path, "Disallow: /\n"); } else + if (strcmp(q_path, "/style.css") == 0) { + FILE *f; + xs *css_fn = xs_fmt("%s/style.css", srv_basedir); + + if ((f = fopen(css_fn, "r")) != NULL) { + *body = xs_readall(f); + fclose(f); + + status = HTTP_STATUS_OK; + *ctype = "text/css"; + } + } + else if (strcmp(q_path, "/share") == 0) { const xs_dict *q_vars = xs_dict_get(req, "q_vars"); const char *url = xs_dict_get(q_vars, "url");