flexmeasures.api.common.utils.decorators

Functions

flexmeasures.api.common.utils.decorators.as_response_type(response_type)

Decorator which adds a “type” parameter to the data of the flask response. Example:

@app.route(‘/postMeterData’) @as_response_type(“PostMeterDataResponse”) @as_json def post_meter_data() -> dict:

return {“message”: “Meter data posted”}

The response.json will be:

{

“message”: “Meter data posted”, “type”: “PostMeterDataResponse”

}

Parameters:

response_type – The response type.

flexmeasures.api.common.utils.decorators.split_response(response: Response) tuple[dict, int, dict]

Split Flask Response object into json data, status code and headers.