20 lines
630 B
PHP
20 lines
630 B
PHP
<?php
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
header('Cache-Control: no-cache'); // pour éviter le buffering du navigateur
|
|
header('X-Accel-Buffering: no'); // si nginx, pour désactiver le buffering
|
|
|
|
$reponse = `python markov.py`;
|
|
|
|
// désactiver le buffering PHP
|
|
@ini_set('output_buffering', 'off');
|
|
@ini_set('zlib.output_compression', 'off');
|
|
while (ob_get_level()) ob_end_flush();
|
|
flush();
|
|
|
|
// envoyer chaque lettre avec un délai
|
|
$len = strlen($reponse);
|
|
for ($i = 0; $i < $len; $i++) {
|
|
echo $reponse[$i];
|
|
flush(); // forcer l'envoi immédiat
|
|
usleep(40000); // 40ms = 40000 microsecondes
|
|
} |