Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
919645b68d |
30
main.py
Normal file
30
main.py
Normal 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
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