from flask import Blueprint, request
from flask_cors import *

from service.phenotypeIndexService import getData, detailData, getName

phenotypeIndex = Blueprint('phenotypeIndex', __name__)
CORS(phenotypeIndex, support_credentials=True)


@phenotypeIndex.route('/phenotypePage', methods=['GET'])
def phenotypeData():
    # phenotypeIntro = introData()
    phenotypeTbl = getData()
    result = {
        # 'phenotypeIntro': phenotypeIntro,
        'phenotypeTbl': phenotypeTbl
    }
    return result


@phenotypeIndex.route('/phenotypeDetail', methods=['GET'])
def phenotypeDetail():
    # phenotypeIntro = introData()
    disease = request.args.get('meshId')
    phenotypeTbl = detailData(disease)
    name = getName(disease)
    result = {
        # 'phenotypeIntro': phenotypeIntro,
        'phenotypeTbl': phenotypeTbl,
        'name': name
    }
    return result
