File size: 1,128 Bytes
7d200f3
 
fb12fe1
 
70c5320
 
7d200f3
fb12fe1
 
 
 
70c5320
 
 
fb12fe1
70c5320
 
 
7d200f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)