File size: 882 Bytes
8eb674c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, request, jsonify

app = Flask(__name__)

# 1. /hello endpoint
@app.route('/hello', methods=['GET'])
def hello():
    return jsonify({'message': 'Hello, welcome to the RAG 30-day sprint!'})

# 2. /calculate endpoint
@app.route('/calculate', methods=['GET'])
def calculate():
    try:
        a = float(request.args.get('a'))
        b = float(request.args.get('b'))
        result = a + b
        return jsonify({'a': a, 'b': b, 'sum': result})
    except (TypeError, ValueError):
        return jsonify({'error': 'Please provide valid numbers using ?a=5&b=10'}), 400

# 3. /ai-ready endpoint
@app.route('/ai-ready', methods=['GET'])
def ai_ready():
    return jsonify({
        'message': 'You are ready to build AI apps. Keep pushing, learn daily, and ship projects!'
    })

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