From 56befa23a18148d470c37e031c041a54925bf429 Mon Sep 17 00:00:00 2001 From: jc <419690370@qq.com> Date: Sun, 9 Mar 2025 18:16:49 +0800 Subject: [PATCH] first commit --- app.py | 26 ++++++++++++++++++++++++++ public/index.html | 15 +++++++++++++++ public/script.js | 14 ++++++++++++++ public/style.css | 21 +++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 app.py create mode 100644 public/index.html create mode 100644 public/script.js create mode 100644 public/style.css diff --git a/app.py b/app.py new file mode 100644 index 0000000..d11218f --- /dev/null +++ b/app.py @@ -0,0 +1,26 @@ +from flask import Flask, jsonify + +app = Flask(__name__, static_folder="public", static_url_path="/static") + + +# 根路径返回 index.html +@app.route("/") +def serve_index(): + return app.send_static_file("index.html") + + +# API 子路径,提供数据 +@app.route("/api/daily-workout") +def api_daily_workout(): + return jsonify({ + "message": "Your daily workout plan", + "data": [ + {"description": "Running", "duration": "30 minutes"}, + {"description": "Yoga", "duration": "1 hour"}, + {"description": "Strength training", "duration": "45 minutes"} + ] + }) + + +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..7103f2f --- /dev/null +++ b/public/index.html @@ -0,0 +1,15 @@ + + + + + Daily Workout Plan + + + +

Daily Workout Plan

+ + + + \ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..04f8c9d --- /dev/null +++ b/public/script.js @@ -0,0 +1,14 @@ +document.addEventListener('DOMContentLoaded', function() { + const dailyWorkouts = [ + { description: "Running", duration: "30 minutes" }, + { description: "Yoga", duration: "1 hour" }, + { description: "Strength training", duration: "45 minutes" } + ]; + + const workoutPlanElement = document.getElementById('workout-plan'); + dailyWorkouts.forEach(workout => { + const li = document.createElement('li'); + li.textContent = `${workout.description} - ${workout.duration}`; + workoutPlanElement.appendChild(li); + }); +}); \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..09789d6 --- /dev/null +++ b/public/style.css @@ -0,0 +1,21 @@ +body { + font-family: Arial, sans-serif; + background-color: #f8f4f9; + color: #333; + margin: 0; + padding: 20px; +} + +h1 { + color:black; + text-align: center; +} + +ul { + list-style-type: none; + padding: 0; +} + +li { + margin-bottom: 10px; +} \ No newline at end of file