Compare commits
No commits in common. "v4" and "main" have entirely different histories.
30
main.py
30
main.py
@ -1,30 +0,0 @@
|
|||||||
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
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
functions-framework==1.4.3
|
|
||||||
markupsafe==2.0.1
|
|
||||||
Loading…
Reference in New Issue
Block a user