<?php
require_once dirname(__DIR__).'/gateway/ProductionGateway.php';
$g=new ProductionGateway();
$d=$_GET['race_date']??date('Y-m-d');
$p=$g->execute($d);
$file=__DIR__.'/gateway_'.$d.'.json';
file_put_contents($file,json_encode($p,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
header('Content-Type: application/json');
echo json_encode(['status'=>'OK','file'=>$file,'bytes'=>filesize($file)]);
