示例#1
0
 async def post(self) -> Response:
     """
     POST handler to parse given reports
     """
     data = await request.data
     params = self.validate_params(report=data.decode() or None)
     if isinstance(params, dict):
         return self.make_response(params, code=400)
     handler = getattr(handle, self.report_type).parse_given
     data, code = handler(params.report, params.options)
     if "station" in data:
         rtype = self.report_type + "-given"
         counter.increment_station(data["station"], rtype)
     return self.make_response(data, params.format, code)
示例#2
0
 async def get(self, params: structs.Params) -> Response:
     """
     GET handler returning multiple reports
     """
     locs = getattr(params, self.loc_param)
     nofail = params.onfail == "cache"
     handler = getattr(handle, self.report_type).handle_report
     coros = []
     for loc in locs:
         coros.append(handler(loc, params.options, nofail))
         counter.increment_station(loc.icao, self.report_type + "-multi")
     results = await aio.gather(*coros)
     keys = [loc.icao if hasattr(loc, "icao") else loc for loc in locs]
     data = dict(zip(keys, [r[0] for r in results if r]))
     return self.make_response(data, params.format)
示例#3
0
 async def get(self, params: structs.Params) -> Response:
     """
     Returns raw station info if available
     """
     counter.increment_station(params.station.icao, "station")
     return self.make_response(asdict(params.station), params.format)