Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Snakes in a browser

Snakes in a browser

We all know that Python and Django can be used to write server-side software, but what about the client side? What about the browser? Can you use Python to power client-side interactions? Can you deploy Python logic (such as validation logic) on both the client and the server?

Video: https://www.youtube.com/watch?v=9W2sFRrNJ9A

Russell Keith-Magee

July 31, 2016
Tweet

More Decks by Russell Keith-Magee

Other Decks in Programming

Transcript

  1. A Django project, c.2016 Template URLs Forms V Views Models

    memcached API API V Browser V V  V
  2. A Django project, c.2016 Template URLs Forms V Views Models

    memcached API API V Browser V V  V
  3. A Django project, c.2016 Template URLs Forms V Views Models

    memcached API API V Browser V V  V
  4. Example <p>Name: <input id="data"> <button id="test">Click!</button> </p> <script type="text/python"> from

    browser import document as doc, alert def echo(*args): alert("Hello %s !" % doc["data"].value) doc["test"].bind("click", echo) </script>
  5. Example >>> def clean(username): ... return username.lower() >>> clean.__code__ <code

    object clean at 0x.....> >>> clean.__code__.co_code b'|\x00\x00j\x00\x00\x83\x00\x00S' >>> import base64 >>> base64.encodebytes(clean.__code__.co_code) b'fAAAagAAgwAAUw==\n'