From 9a74569d4c3203a4ac19193010eb6f32b5e7032d Mon Sep 17 00:00:00 2001 From: jc <419690370@qq.com> Date: Mon, 17 Mar 2025 22:44:37 +0800 Subject: [PATCH] first commit --- app.py | 42 ++++++++++++++++++++++++++++++++++++++++++ public/index.html | 20 ++++++++++++++++++++ public/script.js | 33 +++++++++++++++++++++++++++++++++ public/styles.css | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 app.py create mode 100644 public/index.html create mode 100644 public/script.js create mode 100644 public/styles.css diff --git a/app.py b/app.py new file mode 100644 index 0000000..2c20395 --- /dev/null +++ b/app.py @@ -0,0 +1,42 @@ +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/weight-loss-plan") +def weight_loss_plan(): + plan = { + "message": "Welcome to the Weight Loss Plan", + "plan": { + "week1": { + "monday": {"meal": "Salad with grilled chicken", "calories": 300}, + "tuesday": {"meal": "Veggie stir-fry with tofu", "calories": 250}, + "wednesday": {"meal": "Quinoa salad", "calories": 350}, + "thursday": {"meal": "Grilled fish with steamed vegetables", "calories": 400}, + "friday": {"meal": "Lentil soup", "calories": 300}, + "saturday": {"meal": "Greek yogurt with berries", "calories": 200}, + "sunday": {"meal": "Baked sweet potato with cottage cheese", "calories": 350} + }, + "week2": { + "monday": {"meal": "Oatmeal with almond milk", "calories": 300}, + "tuesday": {"meal": "Chicken breast with broccoli", "calories": 350}, + "wednesday": {"meal": "Chickpea salad", "calories": 300}, + "thursday": {"meal": "Turkey burger with lettuce wrap", "calories": 400}, + "friday": {"meal": "Vegetable sushi rolls", "calories": 250}, + "saturday": {"meal": "Smoothie with spinach and banana", "calories": 200}, + "sunday": {"meal": "Egg white omelette with avocado", "calories": 300} + } + } + } + return jsonify(plan) + + +if __name__ == "__main__": + app.run(debug=True,host="0.0.0.0", port=80) \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..cb4b86d --- /dev/null +++ b/public/index.html @@ -0,0 +1,20 @@ + + +
+ + +