Created
October 25, 2015 14:12
-
-
Save gilsondev/441fa154e97fb062d249 to your computer and use it in GitHub Desktop.
Resource class with Falcon Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import falcon | |
try: | |
import ujson as json | |
except Exception as e: | |
import json | |
class LeroleroResource: | |
def on_get(self, req, resp): | |
"""Retorna um dicionario qualquer""" | |
minha_frase = { | |
'frase': "Acima de tudo, e fundamental ressaltar que bla bla bla", | |
'autor': "Gerador de LeroLero" | |
} | |
resp.body = json.dumps(minha_frase) | |
resp.set_header('Content-Type', 'application/json') | |
resp.content_type = "application/json" | |
api = falcon.API() | |
api.add_route('/frase', LeroleroResource()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment