Hi - does anyone have a customization to the .z.ph handler that would allow the caller to receive JSON data, the same way that adding q.csv to the URL would result in a CSV file being returned from the server? TIA
Thanks, but that doesn’t quite work for my needs. Instead of being able to say http://localhost:5000/.json?callfunc and get a JSON, the caller now has to make two requests, one to run the code and save the output on the filesystem, and then another to read the file from html/. And hope there were no requests in between, which can never be guaranteed.
You can do this in one call without saving the table to the filesystem from the client machine, and without needing to tweak the .z.ph (or .h.val) handlers
Note, if you run the same URL via the brower you’ll see the JSON there, it won’t automatically download like CSV files though.
Hope this helps, in lieu of more community suggestions
Thanks, that’s good to know. However, it only appears to work with plain tables, not other structures, e.g. dictionary of tables.
f1:{([]c1:`a`b`c;c2:1 2 3)} / works, but you can do the same with CSV
f1:{ (`t1`t2)! (([]c1:`a`b`c;c2:1 2 3);([]c1:`d`e`f;c2:4 5 6)) } / breaks, even though the structure is serializable through JSON
wget http://localhost:5000/test.json?f1[] -O test.json
--2023-09-12 15:27:40-- http://localhost:5000/test.json?f1[]
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:5000... connected.
HTTP request sent, awaiting response... 400 Bad Request
2023-09-12 15:27:40 ERROR 400: Bad Request.