On Github fergalwalsh / pico-presentation
This is a presentation about Pico but also a web app using Pico.
To fully experience this presentation you should:
It seems you are not running this presentation with the pico server!
Please go back to the previous slide to learn how to run this properly
Python Developer @ Metglobal
// This slide pico.load_as("examples.notes2", "notes2") run.onclick = function(){ notes2.read(1, displayMessage) }
Run
// This slide pico.load_as("examples.example", "example") run.onclick = function(){ example.hello("World", displayMessage) }
Run
// This slide pico.load_as("examples.example1", "example1") run.onclick = function(){ example1.search("world", displayMessage) }
Run
// This slide pico.load_as("examples.example2", "example2") run.onclick = function(){ example2.multiply(6, 7, displayMessage) }
Run
// This slide pico.load_as("examples.example3", "example3") run.onclick = function(){ var today = new Date() example3.days_until_new_year(today, displayMessage) }
Run
// This slide pico.load_as("examples.example5", "example5") slide.querySelector("input").onchange = function(){ var file = this.files[0] example5.upload_image(file, function(filename){ slide.querySelector("img").src = filename }).done(displayMessage) }
// This slide pico.load_as("examples.example6", "example6") run.onclick = function(){ example6.where(function(point){ displayMessage(JSON.stringify(point)) }) }
Run
pico.load_as("examples.notebook", "notebook") run.onclick = function(){ var nb = new notebook.Notebook("fergalwalsh") nb.notes_list(showNoteList) }
pico.load_as("examples.notebook", "notebook") run.onclick = function(){ var nb = new notebook.Notebook() pico.authenticate(nb, "fergalwalsh", "test") nb.notes_list(showNoteList) }
curl --user "fergalwalsh:test" \ http://localhost:8800/pico/notebook/Notebook/notes_list/
pico.load_as("examples.streaming", "streaming") run.onclick = function(){ streaming.notifications(function(time){ var d = new Date(time) displayMessage(d.toLocaleString()) }) }
Run
client.py: A python Pico client (for RPC)
Any http lib: the protocol is easier than REST!Easily call your api from iOS, Android
cURL
pico.load("example")
http://localhost:8800/pico/example
example.hello()
/pico/example/hello
example.hello("world")
/pico/example/hello?message="world"
nb = notes.Notebook()
!
nb.read(10)
/pico/notes/Notebook/read?id=10
nb.save(note)
/pico/notes/Notebook/save?note='{"id":10, "content": "Bla bla"}'
nb = notes.Notebook("stuff")
!
nb.read(10)
notes/Notebook/read?id=10&_init=["stuff"]
What ever you want! This is not REST!
pico.js usually uses POST, except when a function call has no arguments
Development server: python -m pico.server
WSGI handler: e.g. Apache mod_wsgi, uwsgi, gunicorn, gevent.pywsgi
Google App Engine
django-pico: use Pico as part of a larger Django project
Python >= 2.7 < 3.0 (untested with Python 3.x)
gevent (Optional, needed to use streaming functions)
No other external Python libraries required.
No external JS libraries required (jQuery not required!)