Viewing File: /home/ubuntu/codegamaai-test/tax_bot/app.py
import os
from fastapi.middleware.cors import CORSMiddleware
from fastapi import FastAPI,Form,BackgroundTasks
from supertokens_fastapi import get_cors_allowed_headers
import uvicorn
import shutil
from fastapi import FastAPI
from threading import Thread
from src.constants import *
from src.utils import *
from main_v4 import *
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"] + get_cors_allowed_headers(),
)
@app.post("/api/v1/query")
async def query(data:dict):
question = data['question']
uuid = data['uuid']
# If country code is not provided, default to India
if 'country_code' not in data:
country_code = "IN"
else:
country_code = data['country_code']
# country_code = data['country_code']
response = data_querying(question, uuid, country_code)
return {"response": response}
@app.post("/api/v1/calculate-tax")
async def calculator_in(data:dict):
uuid = data['uuid']
if 'country_code' not in data:
response = {"tax_old_regime": None, "tax_new_regime": None, "status": "fail", "message": "Country code not provided"}
return response
else:
if data['country_code'] != "IN":
response = {"tax_old_regime": None, "tax_new_regime": None, "status": "fail", "message": "Country code not supported"}
return response
else:
country_code = data['country_code']
# Check all the required fields are present
location = data['location']
basic_salary = int(data['basic_salary'])
dearness_allownces = int(data['dearness_allownces'])
hra = int(data['hra'])
hra_actual = int(data['hra_actual'])
special_allowance = int(data['special_allowance'])
pf_deduction = int(data['pf_deduction'])
deduction_80c = int(data['deduction_80c'])
pt_deduction = int(data['pt_deduction'])
deduction_80d = int(data['deduction_80d'])
deduction_NPS = int(data['deduction_NPS'])
deduction_80G = int(data['deduction_80G'])
deduction_interest_on_loan = int(data['deduction_interest_on_loan'])
tax_old_regime = deduction_old_regime(location, basic_salary, dearness_allownces, hra, hra_actual, special_allowance, pf_deduction, deduction_80c, pt_deduction, deduction_80d, deduction_NPS, deduction_80G, deduction_interest_on_loan)
tax_new_regime = deduction_new_regime(basic_salary, dearness_allownces, hra, special_allowance)
return {"tax_old_regime": tax_old_regime, "tax_new_regime": tax_new_regime, "status": "success", "message": "Tax calculation successful"}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0",port=5004,ssl_keyfile="privkey.pem",ssl_certfile="fullchain.pem")
Back to Directory
File Manager