Automatic push from FunctionsAPI

This commit is contained in:
FunctionsAPI 2025-06-29 13:09:19 +00:00
parent 7d580917b6
commit 2cb7cc20b6
3 changed files with 33 additions and 2 deletions

View File

@ -1,2 +1 @@
# 49f236b836c4431cb0779d871b5a261e # python hello-world

30
main.py Normal file
View File

@ -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

2
requirements.txt Normal file
View File

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