Spaces:
Sleeping
Sleeping
Commit
·
e45eccd
1
Parent(s):
43e5360
Write app.py
Browse filesUpdating Flask app to render template and handle button actions
app.py
CHANGED
@@ -1,14 +1,22 @@
|
|
1 |
-
from flask import Flask, jsonify
|
2 |
|
3 |
app = Flask(__name__)
|
4 |
|
5 |
@app.route('/')
|
6 |
def home():
|
7 |
-
return
|
8 |
|
9 |
@app.route('/health')
|
10 |
def health():
|
11 |
return jsonify({"status": "ok"})
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
if __name__ == '__main__':
|
14 |
app.run(host='0.0.0.0', port=5000, debug=True)
|
|
|
1 |
+
from flask import Flask, jsonify, render_template, request
|
2 |
|
3 |
app = Flask(__name__)
|
4 |
|
5 |
@app.route('/')
|
6 |
def home():
|
7 |
+
return render_template('index.html')
|
8 |
|
9 |
@app.route('/health')
|
10 |
def health():
|
11 |
return jsonify({"status": "ok"})
|
12 |
|
13 |
+
@app.route('/action1', methods=['POST'])
|
14 |
+
def action1():
|
15 |
+
return jsonify({"result": "You clicked Button 1!"})
|
16 |
+
|
17 |
+
@app.route('/action2', methods=['POST'])
|
18 |
+
def action2():
|
19 |
+
return jsonify({"result": "You clicked Button 2!"})
|
20 |
+
|
21 |
if __name__ == '__main__':
|
22 |
app.run(host='0.0.0.0', port=5000, debug=True)
|