-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
22 lines (20 loc) · 695 Bytes
/
app.py
File metadata and controls
22 lines (20 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route("/", methods=["GET","POST"])
def home():
msg = ""
if request.method == "POST":
name = request.form.get("name","")
subscribe = "subscribe" in request.form
msg = f"Hello {name}. Subscribed: {subscribe}"
return render_template_string("""
<h1>Hello, World!</h1>
<form method="post">
<input name="name" type="text">
<input name="subscribe" type="checkbox">
<button type="submit">Submit</button>
</form>
<div>{{message}}</div>
""", message=msg)
if __name__=="__main__":
app.run(debug=True, host="0.0.0.0", port=5000)