-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.php
executable file
·63 lines (48 loc) · 1.1 KB
/
index.php
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
<?php
include 'sammy.php';
get('/', function() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML5 Document</title>
<meta charset="utf-8" />
</head>
<body>
<div id="results"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>
$('#results').load('/ajax');
</script>
</body>
</html>
<?php
});
get('/users', function($sammy) {
// example.com/users.json
$sammy->format('json', function() {
return json_encode(array('users' => array(
array(
'username' => 'bob',
'api_key' => '5829-akeK-Ai49'
),
array(
'username' => 'sam',
'api_key' => '4938-Akeb-Le32'
)
)));
});
if( !$sammy->format )
return 'Hello';
});
get('/hello/(.*?)', function($sammy) {
$sammy->format('json', function($sammy) {
return json_encode(array('name', $sammy->segment(2)));
});
if( !$sammy->format )
return 'Hello '.$sammy->segment(2);
});
ajax('/ajax', function() {
return 'ha, you found me!';
});
$sammy->run();