diff --git a/README.md b/README.md index ca0023d..ca9945f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# 49f236b836c4431cb0779d871b5a261e - +# python hello-world diff --git a/main.py b/main.py new file mode 100644 index 0000000..5010559 --- /dev/null +++ b/main.py @@ -0,0 +1,30 @@ +from flask import escape, jsonify, Request + +def main(request: Request): + try: + request_json = request.get_json(silent=True) + + # Extract inputs + name = request_json.get("name") + salary = request_json.get("salary") + + # Validation + if not name or not isinstance(salary, (int, float)): + return jsonify({ + "error": "Invalid input. Please provide a string name and numeric salary." + }), 400 + + # Calculation + raise_percentage = 15 + expected_raise = salary * (raise_percentage / 100) + new_salary = salary + expected_raise + + return jsonify({ + "employee_name": name, + "yearly_salary": round(salary, 2), + "expected_raise": round(expected_raise, 2), + "new_salary": round(new_salary, 2) + }) + + except Exception as e: + return jsonify({"error": str(e)}), 500 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