Batavia

Business logic written in Python, compiled to bytecode, and executed at runtime using Batavia.

Source code: luhn.py

To generate the bytecode payload, run the following in a Python 3.4 shell:

        import base64
        import py_compile

        py_compile.compile('luhn.py', cfile='luhn.pyc')
        with open('luhn.py', 'rb') as pyc:
            print(base64.encodebytes(pyc.read()).decode('utf-8'))

            
This will output the base64 encoded bytecode to be copied into the script tag on this page.

There is also a small piece of Javascript bootstrap code in the <head> to expose the Python function as a click handler:

        <script type="text/javascript">
            window.vm = new batavia.VirtualMachine({})
            function validate(node) {
              window.vm.run('luhn', [node])
            }
        </script>