Ga naar inhoud

Python-code

Python draait via Pyodide — CPython gecompileerd naar WebAssembly — in een aparte thread. U hebt geen Python op uw machine nodig.

SymboolRol
inputDe waarde die op de invoerpoort is ontvangen
varsEen dictionary met de runvariabelen
print(...)Schrijft naar het uitvoeringslogboek
De laatste expressieDe waarde daarvan gaat naar de poort result
commandes = input["commandes"]
payees = [c for c in commandes if c["statut"] == "payee"]
total = sum(c["montant"] for c in payees)
print(f"{len(payees)} commandes payées, total {total} €")
{"nombre": len(payees), "total": total}

De standaardbibliotheek van CPython is beschikbaar: json, re, datetime, hashlib, base64, itertools, collections

import hashlib, hmac
signature = hmac.new(
vars["secret"].encode(),
input["corps"].encode(),
hashlib.sha256,
).hexdigest()
{"signature": signature}

Declareer ze in het veld packages van het vakje. Ze worden bij de eerste uitvoering van PyPI gedownload, gecachet, en daarna offline geladen.

Een overschreden timeout of het stoppen van de uitvoering breekt het script af met een KeyboardInterrupt, en beëindigt de thread indien nodig.