Exemple #1
0
 */
// define la zona horaria
date_default_timezone_set('Europe/Madrid');
// requerimientos de archivos
require 'src/Nanite.php';
require 'src/functions.php';
Nanite::get('/', function () {
    header("Content-Type: application/json");
    echo listar();
});
Nanite::get('/delete/([a-zA-Z0-9]+)', function ($id) {
    header("Content-Type: application/json");
    if ($id == 'All') {
        echo borrarAll();
    } else {
        if ($id == 'Active' || $id == 'Completed') {
            echo borrarEstado($id);
        } else {
            echo borrar($id);
        }
    }
});
Nanite::post('/new', function () {
    header("Content-Type: application/json");
    $objDatos = json_decode(file_get_contents("php://input"));
    $texto = '';
    if (isset($objDatos->texto)) {
        $texto = $objDatos->texto;
    }
    echo crear($texto);
});
Nanite::post('/update/([0-9]+)', function ($id) {
Exemple #2
0
/**
 * Shortcut to the Nanite::get() method.
 *
 * @param string $route
 * @param function $function
 */
function get($route, $function)
{
    Nanite::get($route, $function);
}