Automatic push from FunctionsAPI
This commit is contained in:
parent
5b74ce1364
commit
fb32886619
20
main.py
Normal file
20
main.py
Normal file
@ -0,0 +1,20 @@
|
||||
from flask import jsonify
|
||||
|
||||
def main(request):
|
||||
request_json = request.get_json(silent=True, force=True)
|
||||
# :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
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
functions-framework==1.4.3
|
||||
markupsafe==2.0.1
|
||||
Loading…
Reference in New Issue
Block a user