# import datetime import os import gradio as gr import numpy as np import pandas as pd os.environ["no_proxy"] = "localhost,127.0.0.1,::1" def read_ui(username, password): user_login_df = pd.read_csv( "./user_login/login.csv", encoding="gbk", converters={"password": str} ) user_login = user_login_df.set_index("username")["password"].T.to_dict() user_data_df = pd.read_csv("./user_data/data.csv", encoding="gbk") results = "" is_usn = username in user_login if is_usn: pswd_crct = password == user_login[username] if is_usn and pswd_crct: report = user_data_df[user_data_df["username"] == username] report = np.array(report).tolist() results = "用户名:" + username + "\n" for i in range(len(report)): line = report[i] results = ( results + "第" + str(i + 1) + "次测试 " + "日期:" + str(line[1]) + " 时间:" + str(line[2]) + "评分:" + str(line[3]) + " 评语:" + str(line[4]) + "\n" ) elif is_usn: results = "密码错误,无法读取报告数据。" else: results = "账户不存在,无法读取报告数据。" return results def clear_info(): return ( gr.Textbox(""), gr.Textbox(""), gr.Textbox(""), ) with gr.Blocks() as get_user_data: with gr.Row(): gr.HTML("