Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
732 B
10
Indexable
Never
from flask import Flask, jsonify, request
app = Flask(__name__)
numbers = [3, 5, 1, 8, 2, 9, 4, 6, 7]
@app.route('/stats', methods=['GET'])
def get_statistics():
    if not request.args:
        return jsonify({
            'min': min(numbers),
            'max': max(numbers),
            'average': sum(numbers) / len(numbers)
        })
    if 'min' in request.args:
        return jsonify({'min': min(numbers)})
    if 'max' in request.args:
        return jsonify({'max': max(numbers)})
    if 'average' in request.args:
        return jsonify({'average': sum(numbers) / len(numbers)})
    return jsonify({'error': 'Bilinmeyen parametreler'}), 400
if __name__ == '__main__':
    app.run(debug=True,port=8481)
Leave a Comment