#include #include #include #include extern char **environ; int handle_post(void) { printf("Status: 301 Found\r\n"); printf("Location: http%s://%s%s\r\n\r\n", getenv("HTTPS") ? "s" : "", getenv("HTTP_HOST"), getenv("DOCUMENT_URI")); return 0; } int show_entry(const char *path) { printf("Status: 200 OK\r\n"); printf("Content-Type: text/plain\r\n\r\n"); puts(path); return 0; } int main(void) { char *method = getenv("REQUEST_METHOD"); if (!strcmp(method, "POST")) { return handle_post(); } char *path_info = getenv("PATH_INFO"); if (path_info && *path_info && strcmp(path_info, "/")) { return show_entry(path_info); } printf("Status: 200 OK\r\n"); printf("Content-Type: text/html\r\n\r\n"); puts(""); puts(""); puts(""); puts("Jakob Kaivo/blog"); puts(""); puts(""); puts(""); puts(""); printf("
\n", getenv("DOCUMENT_URI")); puts("Username:
"); puts("Password:
"); puts("Title:
"); puts("
"); puts(""); puts("
"); puts("
");
	for (char **e = environ; e && *e; e++) {
		puts(*e);
	}
	puts("
"); puts(""); puts(""); return 0; }