Spaces:
Sleeping
Sleeping
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") | |
def getResponse_Pan(): | |
return ocrPan(mode, session) | |
def getResponse_Adhaar(): | |
return ocrAdhaar(mode, session) | |
# Route to generate captcha | |
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 | |
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) |