Example #1
0
def timetable(iata_code):
    @after_this_request
    def add_header(response):
        response.headers['Content-type'] = 'application/json'
        return response

    parser = registry.initialize(iata_code)
    records = parser.run()
    return records.to_json()
Example #2
0
def timetable(iata_code):
    @after_this_request
    def add_header(response):
        response.headers['Content-type'] = 'application/json'
        return response

    parser = registry.initialize(iata_code)
    records = parser.run()
    return records.to_json()
Example #3
0
    def get(self, iata_code, _type=None):
        client = tornado.httpclient.AsyncHTTPClient()
        try:
            parser = registry.initialize(iata_code)
        except TypeError:
            self.set_status(404)
            self.write({
                'status': 'error',
                'message': 'Airport {} not found'.format(iata_code)
            })
            self.finish()
        else:
            records = yield parser.run_async()
            self.write(records.to_json())

            self.set_header('Content-Type', 'application/json')
            self.finish()
    def get(self, iata_code, _type=None):
        client = tornado.httpclient.AsyncHTTPClient()
        try:
            parser = registry.initialize(iata_code)
        except TypeError:
            self.set_status(404)
            self.write({
                'status': 'error',
                'message': 'Airport {} not found'.format(iata_code)
            })
            self.finish()
        else:
            records = yield parser.run_async()
            self.write(records.to_json())

            self.set_header('Content-Type', 'application/json')
            self.finish()