From fcc3d6bdafb42902acf34eb3930c0b188ec63dd5 Mon Sep 17 00:00:00 2001 From: FunctionsAPI Date: Mon, 30 Jun 2025 08:36:33 +0000 Subject: [PATCH] Automatic push from FunctionsAPI --- README.md | 3 +-- main.py | 24 ++++++++++++++++++++++++ requirements.txt | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 main.py create mode 100644 requirements.txt diff --git a/README.md b/README.md index 43e56f0..ca9945f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# accb5fe16bf24661a5f800c9445f8a0b - +# python hello-world diff --git a/main.py b/main.py new file mode 100644 index 0000000..6e562a0 --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +from flask import jsonify +import json + +def main(request): + # request_json = request.get_json(silent=True) + data = request.get_data() + request_json = json.loads(data) + print(data) + # :white_check_mark: 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") + # :white_check_mark: 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), + }) \ No newline at end of file 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