diff --git a/README.md b/README.md index 3aa6aa9..ca9945f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# 4d516a68c06041d4b15fb45df2d49900 - +# python hello-world diff --git a/main.py b/main.py new file mode 100644 index 0000000..9ddbc70 --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +from flask import jsonify + +def main(request): + request_json = request.get_json(silent=True) + + # ✅ Check if body was parsed successfully + if request_json is None: + return jsonify({"error": "Invalid or missing JSON in request body."}), 400 + + name = request_json.get("name") + salary = request_json.get("salary") + + # ✅ Validate input fields + if not name or not isinstance(salary, (int, float)): + return jsonify({ + "error": "Invalid input. 'name' must be a string and 'salary' must be a number." + }), 400 + + raise_percentage = 15 + expected_raise = salary * (raise_percentage / 100) + new_salary = salary + expected_raise + + return jsonify({ + "expected_raise": round(expected_raise, 2), + }) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..55e8614 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +functions-framework==1.4.3 +markupsafe==2.0.1