commit
56befa23a1
4 changed files with 76 additions and 0 deletions
@ -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) |
@ -0,0 +1,15 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<title>Daily Workout Plan</title> |
||||
|
<link rel="stylesheet" href="/static/style.css"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>Daily Workout Plan</h1> |
||||
|
<ul id="workout-plan"> |
||||
|
<!-- Workout plan will be dynamically inserted here --> |
||||
|
</ul> |
||||
|
<script src="/static/script.js"></script> |
||||
|
</body> |
||||
|
</html> |
@ -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); |
||||
|
}); |
||||
|
}); |
@ -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; |
||||
|
} |
Loading…
Reference in new issue