Compare commits

...

1 Commits
main ... v4

Author SHA1 Message Date
FunctionsAPI
fcc3d6bdaf Automatic push from FunctionsAPI 2025-06-30 08:36:33 +00:00
3 changed files with 27 additions and 2 deletions

View File

@ -1,2 +1 @@
# accb5fe16bf24661a5f800c9445f8a0b
# python hello-world

24
main.py Normal file
View File

@ -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),
})

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
functions-framework==1.4.3
markupsafe==2.0.1