diff mrjunejune/main.c @ 77:c348ac875294

[Seobeo] Server side rendering.
author June Park <parkjune1995@gmail.com>
date Wed, 31 Dec 2025 14:17:40 -0800
parents 4532ce6d9eb8
children e7bf9e002850
line wrap: on
line diff
--- a/mrjunejune/main.c	Wed Dec 31 14:11:21 2025 -0800
+++ b/mrjunejune/main.c	Wed Dec 31 14:17:40 2025 -0800
@@ -8,6 +8,21 @@
   stop_server = 1;
 }
 
+Seobeo_Request_Entry* GetHomePage(Seobeo_Request_Entry *req, Dowa_Arena *arena)
+{
+  Seobeo_Request_Entry *resp = NULL;
+  char *body = Dowa_Arena_Allocate(arena, 10 * 1024);
+  size_t body_size = 0; 
+  char *file_content = Seobeo_Web_LoadFile("/index.html", &body_size);
+  snprintf(body, 10 * 1024, file_content);
+  free(file_content);
+
+  Dowa_HashMap_Push_Arena(resp, "body", body, arena);
+  return resp;
+}
+
+
+
 Seobeo_Request_Entry* GetUser(Seobeo_Request_Entry *req, Dowa_Arena *arena)
 {
   void *id_kv = Dowa_HashMap_Get_Ptr(req, ":id");
@@ -25,6 +40,6 @@
 int main(void)
 {
   Seobeo_Router_Init();
-  Seobeo_Router_Register("GET", "/v1/users/:id", GetUser);
+  Seobeo_Router_Register("GET", "/", GetHomePage);
   Seobeo_Web_Server_Start("mrjunejune/pages", "6969", SEOBEO_MODE_EDGE, 2);
 }