TestAPI / app /api.py
Pavan+2-at-244075126032
REver ocr changes
70c5320
from app.routes.uidaiServices import generate_captcha, validate_aadhaar
from flask import Blueprint, request, jsonify
import requests
import os
from .routes.adhaarApi import ocrAdhaar
from .routes.panApi import ocrPan
import uuid
ocr_bp = Blueprint('ocr', __name__)
session = requests.Session()
mode = os.getenv("PROJECT_MODE")
@ocr_bp.route('/ocrPan', methods=['POST'])
def getResponse_Pan():
return ocrPan(mode, session)
@ocr_bp.route('/ocrAdhaar', methods=['POST'])
def getResponse_Adhaar():
return ocrAdhaar(mode, session)
# Route to generate captcha
@ocr_bp.route('/generateCaptcha', methods=['POST'])
def get_response_captcha():
# Generate a new UUID for transactionId
transaction_id = uuid.uuid4()
result = generate_captcha(transaction_id)
return jsonify(result)
# Route to validate Aadhaar data
@ocr_bp.route('/validateData', methods=['POST'])
def get_response_uidai():
data = request.json
if not data or 'transactionId' not in data:
return jsonify({"error": "transactionId is required in the request body"}), 400
result = validate_aadhaar(data)
return jsonify(result)