$ curl http://localhost:8080\ /api/v1/poems
["this-is-a-photo", "a-question"]
/api/v1/poems?page=3
/api/v1/poems/page/3
/api/v1/poems_archive/2009/11
$ curl -i \
--header "Range: page=3" \
http://localhost:8080/api/v1/poems
HTTP/1.1 206 Partial Content Content-Type: application/json Transfer-Encoding: chunked Content-Range: page=3 Date: Fri, 15 Nov 2013 09:50:51 GMT Server: localhost
/api/v1/poems?since_id=foo&count=20
def listpoems( db, count, since_id ): ids = ( id for id in db.poems ) # Skip up to since_id ids = itertools.dropwhile( lambda id: id != since_id, ids ) # Skip 1 more ids = itertools.islice( ids, 1, None )
def listpoems( db, count, since_id ): # ... # Stop when we reach count items ids = itertools.islice( ids, 0, count ) return ids
# poems.py
def GET( self, urlid ):
# ...
return json_poems.GET(
self.db, clean(urlid),
web.input()
)
<link rel="next" href="...feed.atom?page=2" />
Videos | youtube.com/user/ajbalaam |
---|---|
@andybalaam | |
Blog | artificialworlds.net/blog |
Projects | artificialworlds.net |