{{define "playground"}}
Open a file from the tree, or load a sample.
Press Run to call the script. What it sends with sendResp() or sendJSONResp() shows here, as the browser would receive it.
Scripts in web/ run like a WebApp backend called with ao_module_agirun(): POST fields become global variables, a JSON body also sets POST_data. Scripts on user:/ or tmp:/ run like a serverless endpoint, with REQ_METHOD, getPara(), postPara() and readBody().
The playground has no network. The first rule matching the method and URL answers; URLs may use * or a /regular expression/. Bodies may use {{"{{"}}url{{"}}"}}, {{"{{"}}method{{"}}"}} and {{"{{"}}body{{"}}"}}.
Each function returns the JSON envelope below, after checking the image file exists. options.async returns a finished job you can read with cnn.job(id).
After websocket.upgrade() the browser sends these frames, each after a wait. While a script runs you can also type frames in the WebSocket output tab.
Functions of these libraries return the JSON you set here (null when nothing is set), and every call is listed under Services in the output.
The first rule whose function matches and whose SQL contains the text (or matches a /regex/) answers. Otherwise exec returns {lastInsertId:0, rowsAffected:0}, query [] and queryRow null.