-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
47 lines (37 loc) · 1.47 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask import Flask, render_template, request, jsonify
from calc import salary_breakdown,find_gross_salary # Replace 'your_python_module' with the actual module where salary_breakdown is defined
app = Flask(__name__, static_folder='static')
@app.route('/')
def index():
return render_template('index.html')
@app.route('/net_salary_simulator')
def net_salary_simulator():
return render_template('net_salary_simulator.html')
@app.route('/calculate-salary', methods=['POST'])
def calculate_salary():
try:
# Get salary input from the request
data = request.get_json()
salary = float(data['salary'])
# Call your Python function to calculate the salary breakdown
result = salary_breakdown(salary)
# Return the result as JSON
return jsonify(result)
except Exception as e:
# Handle errors gracefully
return jsonify({'error': str(e)})
@app.route('/net-salary', methods=['POST'])
def net_salary_sim():
try:
# Get salary input from the request
data = request.get_json()
salary = float(data['salary'])
# Call your Python function to calculate the salary breakdown
result = salary_breakdown(find_gross_salary(salary))
# Return the result as JSON
return jsonify(result)
except Exception as e:
# Handle errors gracefully
return jsonify({'error': str(e)})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)