Spaces:
Sleeping
Sleeping
Commit ·
75ab4e4
1
Parent(s): 4102175
fix url error.
Browse files- flask_app/flask_app.py +4 -8
flask_app/flask_app.py
CHANGED
|
@@ -6,16 +6,12 @@ import json
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
-
@app.route("/")
|
| 10 |
-
def read_root():
|
| 11 |
-
return jsonify({"service": "FlaskAPI", "status": "running"})
|
| 12 |
-
|
| 13 |
@app.route("/health")
|
| 14 |
def health_check():
|
| 15 |
-
return jsonify({"status": "healthy"})
|
| 16 |
|
| 17 |
# 首页路由
|
| 18 |
-
@app.route("/
|
| 19 |
def home():
|
| 20 |
# return "欢迎来到 Flask Demo!<br><a href='/hello'>去打招呼</a> | <a href='/form'>填写表单</a>"
|
| 21 |
return render_template("index.html", message="欢迎来到 Flask Demo!")
|
|
@@ -26,7 +22,7 @@ def home():
|
|
| 26 |
def hello(name=None):
|
| 27 |
if name is None:
|
| 28 |
name = "访客"
|
| 29 |
-
return f"<h1>你好,{name}!</h1><a href='/'>返回首页</a>"
|
| 30 |
|
| 31 |
# 表单页面
|
| 32 |
@app.route("/form", methods=["GET", "POST"])
|
|
@@ -40,5 +36,5 @@ def form():
|
|
| 40 |
<input type="text" name="username" required>
|
| 41 |
<button type="submit">提交</button>
|
| 42 |
</form>
|
| 43 |
-
<a href='/'>返回首页</a>
|
| 44 |
"""
|
|
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@app.route("/health")
|
| 10 |
def health_check():
|
| 11 |
+
return jsonify({"status": "healthy running", "service": "FlaskAPI"})
|
| 12 |
|
| 13 |
# 首页路由
|
| 14 |
+
@app.route("/")
|
| 15 |
def home():
|
| 16 |
# return "欢迎来到 Flask Demo!<br><a href='/hello'>去打招呼</a> | <a href='/form'>填写表单</a>"
|
| 17 |
return render_template("index.html", message="欢迎来到 Flask Demo!")
|
|
|
|
| 22 |
def hello(name=None):
|
| 23 |
if name is None:
|
| 24 |
name = "访客"
|
| 25 |
+
return f"<h1>你好,{name}!</h1><a href='./'>返回首页</a>"
|
| 26 |
|
| 27 |
# 表单页面
|
| 28 |
@app.route("/form", methods=["GET", "POST"])
|
|
|
|
| 36 |
<input type="text" name="username" required>
|
| 37 |
<button type="submit">提交</button>
|
| 38 |
</form>
|
| 39 |
+
<a href='./'>返回首页</a>
|
| 40 |
"""
|