Return the sum of a list of integers in Flask

Write a Flask route that returns the sum of a list of integers.

Problem

Given a list of integers, write a Flask route that returns the sum of the integers in the list.
Example input: [1, 2, 3, 4, 5]
Example output: 15

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
# The optimal solution is to use the sum() function.
# This is optimal because it is a built-in function that is already optimized.
# It is also optimal because it is a one-liner.

@app.route('/sum', methods=['POST'])
def sum():
    data = request.get_json()
    return jsonify(sum(data))

if __name__ == '__main__':
    app.run(debug=True)

A.I. Evaluation of the Solution

This solution is correct and demonstrates a level of completeness. The candidate has used the sum() function, which is an optimal solution. The candidate has also used a one-liner, which is also optimal.

Evaluated at: 2022-11-18 10:16:09