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

B91373320dbc3bc52fcd870d3b21748f?s=128

Russell Keith-Magee

July 31, 2016
Tweet

Transcript

  1. Snakes in a Browser Dr Russell Keith-Magee PyOhio 2016

  2. Snakes in a Browser Dr Russell Keith-Magee PyOhio 2016

  3. None
  4. None
  5. Quo vadimus?

  6. 2005

  7. A Django project, c.2005 Browser

  8. A Django project, c.2005 Models Browser

  9. A Django project, c.2005 Views Models Browser

  10. A Django project, c.2005 Forms V Views Models Browser

  11. A Django project, c.2005 URLs Forms V Views Models Browser

  12. A Django project, c.2005 Template URLs Forms V Views Models

    Browser
  13. A Django project, c.2005 Template URLs Forms V Views Models

    memcached Browser
  14. A Django project, c.2016 Template URLs Forms V Views Models

    memcached Browser
  15. A Django project, c.2016 Template URLs Forms V Views Models

    memcached Browser V
  16. A Django project, c.2016 Template URLs Forms V Views Models

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

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

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

    memcached API API V Browser V V  V
  20. Rich client frameworks

  21. Isomorphic Javascript Development

  22. Integrating with Python

  23. Isomorphic Javascript Development

  24. Isomorphic Javascript Development

  25. Analyse requirements Browser

  26. Analyse requirements Browser

  27. Analyse requirements Browser

  28. Analyse requirements V Browser V

  29. Analyse requirements V Browser V V  V

  30. Everything old is new again

  31. Revised Web app structure V Models Browser V V 

    V
  32. Revised Web app structure V Models Browser V Views V

     V
  33. Revised Web app structure Controller V Models Browser V Views

    V  V
  34. Model - View - Controller

  35. API-first development

  36. High latency connections or No connection at all

  37. Python in the browser

  38. Brython Skulpt PyPy.js

  39. 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>
  40. Analysing requirements

  41. .pyc files and bytecode

  42. Batavia

  43. 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'
  44. Example: DOM access import dom div = dom.document.getElementById('output') div.innerHTML =

    div.innerHTML + '\n\nHello, World!\n\n'
  45. Unexpected consequences

  46. Python on Mobile devices

  47. Toga

  48. Toga for web?

  49. freakboy3742.pythonanywhere.com

  50. Ágætis byrjun

  51. Possible isn't enough

  52. russell@keith-magee.com @freakboy3742 cecinestpasun.com pybee.org freakboy3742.pythonanywhere.com