import pandas as pd import gradio as gr # Function to fetch and read the Excel file from SharePoint def fetch_data_from_sharepoint(url): #response = requests.get(url) #response.raise_for_status() #file_bytes = BytesIO(response.content) return pd.read_excel(sharepoint_url, sheet_name='Sheet1') # URL of the shared Excel file sharepoint_url = "Lista de Estudiantes (2).xlsx" # Load the data try: data = fetch_data_from_sharepoint(sharepoint_url) except Exception as e: print(f"Error loading the data: {e}") data = pd.DataFrame() # Empty DataFrame to avoid breaking the interface def obtener_notas(cc): if data.empty: return "No se pudo cargar los datos del archivo en SharePoint." try: cc = int(cc) # Ensure CC is an integer except ValueError: return "El número de cédula debe ser numérico.", "","","","","" estudiante = data[data['CC'] == cc] if estudiante.empty: return "Estudiante no encontrado", "", "","","","" nombre_completo = estudiante['Nombre Completo'].values[0].upper() correo_institucional = estudiante['Correo Institucional (@usanjose.edu.co)'].values[0] autoevaluacion = estudiante['Autoevaluación (10 estrellas es lo más alto)'].values[0] / 2 nota_colab = estudiante['Nota Colab'].values[0] / 2 nota_kahoot = estudiante['Nota Kahoot'].values[0] / 2 nota_final = round(estudiante['Nota Final'].values[0],1) resultados = ( nombre_completo, correo_institucional, autoevaluacion, nota_colab, nota_kahoot, nota_final ) return resultados # Gradio Interface using components with gr.Blocks() as demo: inputs = gr.Textbox(label="HE DESHABILITADO LA APP, POR FAVOR CONTACTE A LA UNIVERSIDAD PARA SUS PETICIONES.
. ATENTAMENTE: PROFESOR HERNAN DAVID TORRES
. Ingrese su número de cédula CC") greet_btn = gr.Button("Consultar nota") outputs = [ gr.Textbox(label="Nombre"), gr.Textbox(label="Correo Institucional"), gr.Textbox(label="Autoevaluación"), gr.Textbox(label="Nota Colab"), gr.Textbox(label="Nota Kahoot"), gr.Textbox(label="Nota Final (50% docente, no incluye nota entregable)"), ] greet_btn.click(fn=obtener_notas, inputs=inputs, outputs=outputs, api_name="greet") demo.launch(debug=True)