Added dynamic pages with dynamic linking during runtime

This commit is contained in:
Nate Choe
2022-02-14 12:08:09 -06:00
parent 8df741a078
commit 6825f12163
28 changed files with 435 additions and 84 deletions

2
example/Makefile Normal file
View File

@@ -0,0 +1,2 @@
library.so: library.c
$(CC) $< -o $@ -shared -I../src/

14
example/library.c Normal file
View File

@@ -0,0 +1,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <swebs/swebs.h>
int getResponse(Request *request, Response *response) {
char *str = "<h1>Hello world!</h1>";
response->type = BUFFER;
response->response.buffer.data = malloc(30);
strcpy(response->response.buffer.data, str);
response->response.buffer.len = strlen(str);
return 200;
}

View File

@@ -1,3 +1,3 @@
#!/bin/sh
../build/swebs -P swebs.pid -s sitefile -o logs -p 8000 -b 100 -j2
../build/swebs -p swebs.pid -s sitefile -o logs -b 100 -j2

View File

@@ -1,7 +1,10 @@
define port 8000
#define transport TLS
define key domain.key
define cert domain.crt
define timeout 2000
define library ./library.so
set host localhost:8000
read / site/index.html
@@ -10,7 +13,7 @@ throw /blog/forbidden 403
exec /blog/2022-1-31 site/blog/blog/2022-1-31.sh
read /blog/.* site/blog/
#/blog/2021-1-25.html turns into site/blog//blog/2021-1-25.html
exec /dynamic site/build-page.sh
linked /library
set host 127.0.0.1:8000
read / site/easteregg.html
read /egg.png site/egg.png