I have a route in my flask app that starts off like this:
@app.route('/invocations', methods=['POST'])
def predict():
    """
    Do an inference on a single batch of data.
    """
    if flask.request.content_type == 'text/csv':
        X_train = flask.request.data.decode('utf-8')
        X_train = pd.read_csv(StringIO(X_train), header=None).values
To test this path I am sending a POST request to the server from a csv formatted file with multiple lines in it: curl -X "POST" -H "Content-Type: text/csv" -d @health-check-data.csv http://localhost:5000/invocations.
However, to my surprise, when I execute X_train = flask.request.data.decode('utf-8'), I get the contents of the csv concatenated into a single string with newlines removed.
Why is flask (or curl?) doing this, and how do I get around this behavior?
 
    