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.
26 lines
673 B
26 lines
673 B
1 month ago
|
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)
|