-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.c
63 lines (49 loc) · 1.45 KB
/
hello.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sqlite3.h>
#include "libctemplate/ctemplate.h"
#include "server/server.h"
int indexPage(Response *resp, Request *req)
{
<<<<<<< HEAD
char *name = getRequestPostField(req, "name");
// char *age = getRequestPostField(req, "age");
resp->TMPL_file = setPath("index.html");
resp->TMPL_mainlist = TMPL_add_var(resp->TMPL_mainlist,
"hello", "I'm the index page.",
"name", name, 0);
return 0;
=======
resp->TMPL_file = setPath("index.html");
return HTTP_OK;
>>>>>>> example-app
}
int helloPage(Response *resp, Request *req)
{
<<<<<<< HEAD
resp->TMPL_file = setPath("index.html");
TMPL_loop *loop = 0;
TMPL_varlist *vl;
char *n = getRouteParam(req, 1);
int num = atoi(n ? n : "3");
free(n);
for (int i = num; i > 0; i--)
{
vl = TMPL_add_var(0, "hello", "Hello world!",0);
loop = TMPL_add_varlist(loop, vl);
}
resp->TMPL_mainlist = TMPL_add_loop(resp->TMPL_mainlist, "hello_loop", loop);
return 0;
=======
getUrlEncodedForm(req);
char *name = getUrlEncodedFormField(req, "name");
char *age = getUrlEncodedFormField(req, "age");
printf("%s - %s\n", name, age);
resp->TMPL_file = setPath("hello.html");
resp->TMPL_mainlist = TMPL_add_var(resp->TMPL_mainlist,
"hello", "I'm the index page.",
"name", name, 0);
return HTTP_OK;
>>>>>>> example-app
}