def __init__(self, conf_file=None, *args, **kwargs): here = dirname(dirname(sys.argv[0])) self.config = Config.load(path=conf_file, conf_name="impim_api.conf", lookup_paths=[ here, os.curdir, expanduser('~'), '/etc/', dirname(__file__), ]) rest_api = TornadoRESTful(version='', base_url=self.config.APPLICATION_URL, discovery=True, cross_origin_enabled=True) rest_api.add_resource('alpha/images', ImagesResourceHandler) handlers = [ (r'/healthcheck(?:/|\.html)?', HealthCheckHandler), (r'/thumbor_urls/?', JsonpEnabledThumborUrlHandler), (r'/alpha/images/(?P<key>.+)/.+', ImageHandler), ] + rest_api.get_url_mapping() super(ImagesApplication, self).__init__(handlers, thumbor_security_key=self.config.THUMBOR_SECURITY_KEY, thumbor_server_url=self.config.THUMBOR_SERVER_URL, *args, **kwargs)
def __init__(self, conf_file=None, *args, **kwargs): here = dirname(dirname(sys.argv[0])) self.config = Config.load(path=conf_file, conf_name="impim_api.conf", lookup_paths=[ here, os.curdir, expanduser('~'), '/etc/', dirname(__file__), ]) rest_api = TornadoRESTful(version='', base_url=self.config.APPLICATION_URL, discovery=True, cross_origin_enabled=True) rest_api.add_resource('alpha/images', ImagesResourceHandler) handlers = [ (r'/healthcheck(?:/|\.html)?', HealthCheckHandler), (r'/thumbor_urls/?', JsonpEnabledThumborUrlHandler), (r'/alpha/images/(?P<key>.+)/.+', ImageHandler), ] + rest_api.get_url_mapping() super(ImagesApplication, self).__init__( handlers, thumbor_security_key=self.config.THUMBOR_SECURITY_KEY, thumbor_server_url=self.config.THUMBOR_SERVER_URL, *args, **kwargs)
class TestApiManager(TestCase): def setUp(self): self.api = TornadoRESTful() def test_should_be_possible_to_add_a_handler(self): self.api.add_resource('api', ResourceHandler) assert ('/api/?', ResourceHandler) in self.api.get_url_mapping() def test_should_generate_a_path_for_access_direcly_an_instance(self): self.api.add_resource('comment', ResourceHandler) assert ('/comment/(?P<key>.+)/?', ResourceHandler) in \ self.api.get_url_mapping() def test_should_generate_path_to_handler_return_type_specification(self): self.api.add_resource('comment', ResourceHandler) assert ('/comment\.(?P<force_return_type>\w+)', ResourceHandler) in \ self.api.get_url_mapping() def test_should_generate_path_to_handler_return_type_specification(self): self.api.add_resource('comment', ResourceHandler) assert ('/comment/(?P<key>[^.]+)\.(?P<force_return_type>\w+)', ResourceHandler) in \ self.api.get_url_mapping()
def get_app(self): api = TornadoRESTful() api.add_resource('api', ResourceHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful(cross_origin_enabled=True) api.add_resource('api', WithDefaultCallbackHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful(version='v1', base_url='http://api.tapioca.com') api.add_resource('api', FullTestHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful( version='v1', base_url='http://api.tapioca.com', discovery=True) api.add_resource('comments', ResourceWithDocumentation) return tornado.web.Application(api.get_url_mapping())
#!/usr/local/bin/python2.7 # encoding: utf-8 import tornado.ioloop import tornado.web from tapioca import TornadoRESTful, ResourceHandler class HelloResource(ResourceHandler): def get_collection(self, callback): callback("Hello, world!") api = TornadoRESTful(discovery=True) api.add_resource('hello', HelloResource) application = tornado.web.Application( api.get_url_mapping() ) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
#!/usr/local/bin/python2.7 # encoding: utf-8 import tornado.ioloop import tornado.web from tapioca import TornadoRESTful, ResourceHandler class HelloResource(ResourceHandler): def get_collection(self, callback): callback("Hello, world!") api = TornadoRESTful(discovery=True) api.add_resource('hello', HelloResource) application = tornado.web.Application(api.get_url_mapping()) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def get_app(self): api = TornadoRESTful() api.add_resource('always_valid', NoAccessValuesInQuerystring) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful() api.add_resource('api', ResourceHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful(cross_origin_enabled=True) api.add_resource('api', WithDefaultCallbackHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful(version='v1', base_url='http://api.tapioca.com', discovery=True) api.add_resource('comments', ResourceWithDocumentation) return tornado.web.Application(api.get_url_mapping())
def get_app(self): api = TornadoRESTful() api.add_resource('projects', ProjectsResource) application = tornado.web.Application(api.get_url_mapping()) return application
import tornado.ioloop from tornado.httpserver import HTTPServer from tapioca import TornadoRESTful, ResourceHandler, validate class ProjectsHandler(ResourceHandler): @validate(querystring={'name': (unicode, 'name of project that do you want to search')}) def get_collection(self, callback, *args, **kwargs): callback([{'params': self.values['querystring']}]) if __name__ == '__main__': import os port = int(os.environ.get('PORT', 5000)) main_loop = tornado.ioloop.IOLoop.instance() api = TornadoRESTful(version='', \ base_url='http://tapioqueiro.herokuapp.com', discovery=True, \ cross_origin_enabled=True) api.add_resource('projects', ProjectsHandler) application = tornado.web.Application(api.get_url_mapping()) server = HTTPServer(application) server.bind(port, '0.0.0.0') server.start(1) main_loop.start()
def get_app(self): api = TornadoRESTful(version='v1', base_url='http://api.tapioca.com') api.add_resource('api', FullTestHandler) application = tornado.web.Application(api.get_url_mapping()) return application
def get_app(self): api = TornadoRESTful() api.add_resource('projects', ProjectsResource) application = tornado.web.Application(api.get_url_mapping()) return application