Added dynamic pages with dynamic linking during runtime
This commit is contained in:
2
example/Makefile
Normal file
2
example/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
library.so: library.c
|
||||
$(CC) $< -o $@ -shared -I../src/
|
||||
14
example/library.c
Normal file
14
example/library.c
Normal 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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user