aboutsummaryrefslogtreecommitdiffstats
path: root/endpoints.c
blob: 789f48a3b1d2f8e2c53410a40936a363e1f3e6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdlib.h>
#include <string.h>

#include "microhttpd.h"

#define CONTAINER_IMPLEMENTATION
#define JACSON_IMPLEMENTATION
#include <jacson.h>

// not accessible in browser because ALL URLs start with / (or with _ in dylib)
char* duplicate(const char* x) {
	size_t len = strlen(x);
	char* ret = malloc(len+1);
	memcpy(ret, x, len);
	ret[len] = '\0';
	return ret;
}

// index, path: /
char* _(struct MHD_Connection* connection) {
	const char* resp = "<html><body>This is an index page!</body></html>";
	return duplicate(resp);
}

// home, path: /home
char* _home(struct MHD_Connection* connection) {
	const char* resp = "<html><body>"
		"<h1>This is a HOME page!</h1>"
		"<div style=\"height:10000px;\"></div>"
		"<a href=\"/hidden/hentai\">Don't click me! :0</a>"
		"</body></html>";
	return duplicate(resp);
}

// hentai, path: /hidden/hentai
char* _hidden_hentai(struct MHD_Connection* connection) {
	const char* resp = "<html><style>a{text-decoration:none;}</style><body>"
		"<p>what did you expect to see...</p>"
		"<a href=\"https://pornhub.com\">&nbsp;</a>"
		"</body></html>";
	return duplicate(resp);
}