Skip to content

Instantly share code, notes, and snippets.

@biancarosa
Created September 24, 2016 14:08
Show Gist options
  • Select an option

  • Save biancarosa/09df0cff9b0943982a870e07a05ef396 to your computer and use it in GitHub Desktop.

Select an option

Save biancarosa/09df0cff9b0943982a870e07a05ef396 to your computer and use it in GitHub Desktop.
Falcon sample app (2 resources)
# app.py
import falcon
import json
class SongsResource:
def on_get(self, req, resp):
songs = [
{
"title": "Your Song", "artist": "Elton John"
},
{
"title": "I Want To Break Free", "artist": "Queen"
}
]
resp.body = json.dumps(songs)
class SongResource:
def on_get(self, req, resp):
song = {
"title": "Your Song", "artist": "Elton John"
}
resp.body = json.dumps(song)
api = falcon.API()
api.add_route('/songs', SongsResource())
api.add_route('/song', SongResource())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment