commit e96b88d9c792e91bc6e4ce3428e1951b3d36c569 Author: jc <419690370@qq.com> Date: Sat Mar 15 23:36:56 2025 +0800 first commit diff --git a/app.py b/app.py new file mode 100644 index 0000000..edd980f --- /dev/null +++ b/app.py @@ -0,0 +1,34 @@ +from flask import Flask, jsonify, send_from_directory + +app = Flask(__name__, static_folder="public", static_url_path="") + +# 根路径返回 index.html +@app.route("/") +def serve_index(): + return send_from_directory(app.static_folder, "index.html") + +# API 子路径,提供期末考试复习计划数据 +@app.route("/api/review-plan") +def api_review_plan(): + review_plan_data = { + "message": "期末考试复习计划", + "data": { + "subjects": [ + {"name": "数学", "plan": "每天复习一个章节,做 20 道练习题,重点复习函数和几何部分。"}, + {"name": "语文", "plan": "每天阅读一篇文言文,背诵 5 个成语,练习一篇作文。"}, + {"name": "英语", "plan": "每天背诵 30 个单词,做一套阅读理解题,练习口语 15 分钟。"}, + {"name": "物理", "plan": "每天复习一个物理定律,做 10 道相关习题,总结错题。"}, + {"name": "化学", "plan": "每天背诵 5 个化学方程式,做 10 道选择题,复习元素周期表。"} + ], + "tips": [ + "制定每日复习计划,合理分配时间。", + "保持良好的作息,保证充足的睡眠。", + "复习时保持专注,避免分心。", + "定期进行模拟考试,检验复习效果。" + ] + } + } + return jsonify(review_plan_data) + +if __name__ == "__main__": + app.run(debug=True, port=80) \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..9e98974 --- /dev/null +++ b/public/index.html @@ -0,0 +1,23 @@ + + + + + + 期末考试复习计划 + + + +
+

期末考试复习计划

+
+

科目复习计划

+
+
+
+

复习小贴士

+
+
+
+ + + \ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..56d1876 --- /dev/null +++ b/public/script.js @@ -0,0 +1,38 @@ +document.addEventListener("DOMContentLoaded", function () { + fetch("/api/review-plan") + .then(response => response.json()) + .then(data => { + const subjectsContainer = document.getElementById("subjects-container"); + const tipsContainer = document.getElementById("tips-container"); + + // 渲染科目复习计划 + data.data.subjects.forEach(subject => { + const subjectItem = document.createElement("div"); + subjectItem.classList.add("item"); + + const subjectName = document.createElement("div"); + subjectName.classList.add("item-name"); + subjectName.textContent = subject.name; + + const subjectPlan = document.createElement("div"); + subjectPlan.classList.add("item-description"); + subjectPlan.textContent = subject.plan; + + subjectItem.appendChild(subjectName); + subjectItem.appendChild(subjectPlan); + + subjectsContainer.appendChild(subjectItem); + }); + + // 渲染复习小贴士 + data.data.tips.forEach(tip => { + const tipItem = document.createElement("div"); + tipItem.classList.add("item"); + tipItem.textContent = tip; + tipsContainer.appendChild(tipItem); + }); + }) + .catch(error => { + console.error("Error fetching review plan data:", error); + }); +}); \ No newline at end of file diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..a894304 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,45 @@ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f9; + margin: 0; + padding: 0; +} + +.container { + max-width: 800px; + margin: 20px auto; + padding: 20px; + background: #fff; + border-radius: 8px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); +} + +h1, h2 { + text-align: center; + color: #333; +} + +.section { + margin-top: 20px; +} + +.item { + margin-bottom: 15px; + padding: 10px; + border-bottom: 1px solid #ddd; +} + +.item:last-child { + border-bottom: none; +} + +.item-name { + font-size: 1.2em; + font-weight: bold; + color: #444; +} + +.item-description { + font-size: 0.9em; + color: #666; +} \ No newline at end of file