File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 8
8
"query_url" : " /queries?queries=" ,
9
9
"plaintext_url" : " /plaintext" ,
10
10
"update_url" : " /updates?queries" ,
11
+ "fortune_url" : " /fortunes" ,
11
12
"port" : 8080 ,
12
13
"approach" : " Realistic" ,
13
14
"classification" : " Micro" ,
Original file line number Diff line number Diff line change 60
60
}
61
61
);
62
62
63
+ // Test 4: Fortunes
64
+ $ app ->get ('/fortunes ' , function ($ request , $ response ) {
65
+ $ sth = $ this ->db ->query ('SELECT * FROM fortune ' );
66
+
67
+ $ arr = $ sth ->fetch (PDO ::FETCH_KEY_PAIR );
68
+ $ arr [0 ] = 'Additional fortune added at request time. ' ;
69
+ asort ($ arr );
70
+
71
+ ob_start ();
72
+ include __DIR__ .'/index.tpl.phtml ' ;
73
+ $ html = ob_get_contents ();
74
+ ob_end_clean ();
75
+
76
+ $ body = $ response ->getBody ();
77
+ $ body ->write ($ html );
78
+
79
+ return $ response
80
+ ->withBody ($ body )
81
+ ->withHeader ('Content-Type ' , 'text/html ' );
82
+ }
83
+ );
84
+
63
85
// Test 5: Database updates
64
86
$ app ->get ('/updates ' , function ($ request , $ response ) {
65
87
$ sth = $ this ->db ->prepare ('SELECT * FROM world WHERE id = ? ' );
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head><title>Fortunes</title></head>
4
+ <body>
5
+ <table>
6
+ <tr><th>id</th><th>message</th></tr>
7
+ <?php foreach ($ arr as $ id => $ message ): ?>
8
+ <tr><td><?= $ id?> </td><td><?= $ message?> </td></tr>
9
+ <?php endforeach ; ?>
10
+ </table>
11
+ </body>
12
+ </html>
You can’t perform that action at this time.
0 commit comments