Automatic push from FunctionsAPI

This commit is contained in:
FunctionsAPI 2025-06-29 13:15:39 +00:00
parent df3e004e68
commit e0f511079b
3 changed files with 31 additions and 2 deletions

View File

@ -1,2 +1 @@
# 0799e94d92fc4345a2f5f5c3582e82cf # python hello-world

28
main.py Normal file
View File

@ -0,0 +1,28 @@
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({
"employee_name": name,
"yearly_salary": round(salary, 2),
"expected_raise": round(expected_raise, 2),
"new_salary": round(new_salary, 2)
})

2
requirements.txt Normal file
View File

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