-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathserver.php
More file actions
54 lines (44 loc) · 1.24 KB
/
server.php
File metadata and controls
54 lines (44 loc) · 1.24 KB
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
<?php
require_once __DIR__.'/../../vendor/autoload.php';
use Utopia\App;
use Utopia\Request;
use Utopia\Response;
use Utopia\Validator\Text;
ini_set('memory_limit', '1024M');
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
ini_set('display_socket_timeout', '-1');
error_reporting(E_ALL);
App::get('/')
->inject('response')
->action(function (Response $response) {
$response->send('Hello World!');
});
App::get('/value/:value')
->param('value', '', new Text(64))
->inject('response')
->action(function (string $value, Response $response) {
$response->send($value);
});
App::get('/chunked')
->inject('response')
->action(function (Response $response) {
foreach (['Hello ', 'World!'] as $key => $word) {
$response->chunk($word, $key == 1);
}
});
App::get('/redirect')
->inject('response')
->action(function (Response $response) {
$response->redirect('/');
});
App::get('/humans.txt')
->inject('response')
->action(function (Response $response) {
$response->noContent();
});
$request = new Request();
$response = new Response();
$app = new App('UTC');
$app->setCompression(true);
$app->run($request, $response);