-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteapot.cpp
More file actions
34 lines (29 loc) · 952 Bytes
/
teapot.cpp
File metadata and controls
34 lines (29 loc) · 952 Bytes
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
#include <string.h>
#include "teapot.hpp"
static const char*teapot =
"<html><head></head><body>"
"<div style=\"font-family: monospace; white-space: pre;\">"
" _<br>"
" _,(_)._<br>"
" ___,(_______).<br>"
" ,'__. \\ /\\_<br>"
" /,' / \\ / /<br>"
"| | | |,' /<br>"
" \\`.| /<br>"
" `. : : /<br>"
" `. :.,'<br>"
" `-.________,-'<br>"
"</div>"
"</body></html>\r\n"
;
bool Teapot::matches(const char* verb, const char* path){
bool accept = (strcmp(verb,"GET") == 0) && (strncmp(path, "/coffee",7) == 0);
if(accept) printf("TEAPOT!\n"); else printf("Not a teapot\n");
return accept;
}
void Teapot::process( HttpRequest& request, HttpResponse& response){
response.setStatus(418,"I'm a teapot");
response.addHeader("Server", "PicoW");
response.addHeader("Content-Type", "text/html");
response.setBody(teapot);
}