콘텐츠로 이동

Python 코드

Python은 Pyodide — WebAssembly로 컴파일한 CPython — 를 통해 별도 스레드에서 실행됩니다. 사용하는 컴퓨터에 Python을 설치할 필요는 없습니다.

심볼역할
input입력 포트로 받은 값
vars실행 변수를 담은 딕셔너리
print(...)실행 로그에 기록합니다
마지막 표현식그 값이 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}

CPython의 표준 라이브러리를 사용할 수 있습니다. json, re, datetime, hashlib, base64, itertools, collections 등입니다.

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

박스의 packages 필드에 선언하십시오. 첫 실행 때 PyPI에서 내려받아 캐시에 저장하고, 이후에는 오프라인으로 불러옵니다.

timeout 초과나 실행 중지는 KeyboardInterrupt 로 실행을 끊고, 필요하면 스레드를 종료합니다.