1. JSON becomes values the other languages can read
A JSON block is parsed into named values. It stays in the page, because it is usually the browser's data too.
Four names now exist: who, n,
price and ready — and each keeps its kind. A
number is a number, not the text "21".
2. Python reads them
The block is replaced by whatever it printed, so the visitor gets the answer rather than the program that worked it out.
That last line is Python's own arithmetic: // floors and
/ does not. Getting those two right is why this is a separate
interpreter from the Java one rather than one parser wearing two hats.
3. Java reads the same values
Java's 7 / 2 is 3 — integer division on
int operands — where Python's was 3.5. Same expression, two languages, two
correct answers.
4. The browser's own script is untouched
Anything that is not python, java or json is passed through and runs in the browser as usual:
(if you see this, JavaScript is off)
How this is switched on
Page scripts are off by default. The config that ships with this package turns them on only for this directory:
page_scripts = on script_path = /02-languages page_script_timeout_ms = 5000 script_file_root = <the sites directory>
That is the pattern worth copying. With script_path set,
every other directory is documents — a file dropped into an uploads folder
cannot execute. The timeout means a page that never finishes answers 504
instead of holding a worker for ever, and
script_file_root keeps the file builtins inside the site.
See doc/IWEBSERVER_USER_MANUAL.md §5, and
doc/ICPP_LANGUAGES_GUIDE.md for what each language covers.