diff --git a/app.py b/app.py index 242e44d..fcbe539 100644 --- a/app.py +++ b/app.py @@ -69,9 +69,9 @@ def upload_score(): and "running_time" in data and "time" in data ): - if data["name"]=="test_name": + if data["name"] == "test_name": return jsonify({"message": "请完善姓名,默认名字不记录成绩!"}), 400 - elif data["id"]=="202210423xxx": + elif data["id"] == "202210423xxx": return jsonify({"message": "请完善学号,默认学号不记录成绩!"}), 400 data["details"] = data["details"].replace("\n", "
") write_to_csv(data) @@ -87,8 +87,9 @@ def get_scores(): try: with open(csv_file_path, mode="r", encoding="utf-8") as csvfile: reader = csv.DictReader(csvfile) - scores = list(reader) - return jsonify(scores) + scores = jsonify(list(reader)) + scores.headers.add("Access-Control-Allow-Origin", "*") + return scores except Exception as e: return jsonify({"error": str(e)}), 500 diff --git a/exp/knn/main.py b/exp/knn/main.py index 0e69c43..1dbae4e 100755 --- a/exp/knn/main.py +++ b/exp/knn/main.py @@ -140,8 +140,8 @@ def main(name, id): # 输出结果 print("") - log_details.append(f"得分: {accuracy * 100:.2f}%") - print(f"得分: {accuracy * 100:.2f}%") + log_details.append(f"得分: {accuracy * 100:.2f}") + print(f"得分: {accuracy * 100:.2f}") log_details.append(f"运行时间: {running_time * 1000:.10f}ms") print(f"运行时间: {running_time * 1000:.10f}ms") @@ -149,7 +149,7 @@ def main(name, id): score_data = { "score": accuracy, "running_time": f"{running_time * 1000:.10f}ms", - "details": "\n".join(log_details), + "details": "
".join(log_details), } upload_score(name, id, score_data) diff --git a/index.html b/index.html new file mode 100644 index 0000000..55c7844 --- /dev/null +++ b/index.html @@ -0,0 +1,140 @@ + + + + + + 挑战赛数据展示 + + + +

测试结果

+ + + + + + + + + + + + + +
时间学号名称得分运行时间详细信息
+ + + + +