You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
2.0 KiB

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/swimming-tips")
def swimming_tips():
tips = {
"message": "欢迎来到新手游泳注意事项",
"tips": [
{
"title": "安全第一",
"description": "始终在指定区域内游泳,并遵守游泳池或海滩的规则。不要独自游泳,尤其是新手。"
},
{
"title": "学习基本技能",
"description": "从基本的游泳姿势开始,例如自由泳和仰泳。练习漂浮和踩水,以增强信心。"
},
{
"title": "正确呼吸",
"description": "在水下缓慢呼气,当头部露出水面时快速吸气。练习有节奏的呼吸,保持稳定的节奏。"
},
{
"title": "使用浮力辅助工具",
"description": "可以使用浮板、泳圈或救生衣等辅助工具,帮助你保持浮力并专注于技术练习。"
},
{
"title": "热身和拉伸",
"description": "游泳前一定要热身。拉伸手臂、腿部和背部,以防止受伤。良好的热身可以提高你的表现。"
},
{
"title": "保持水分",
"description": "游泳前后及过程中要多喝水。即使你在水中,也可能会脱水。"
},
{
"title": "听从身体的信号",
"description": "如果感到疲劳,请停下来休息。不要过度劳累,尤其是刚开始学习游泳时。"
}
]
}
return jsonify(tips)
if __name__ == "__main__":
app.run(debug=True,port=80)