-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflaskapp.py
37 lines (28 loc) · 879 Bytes
/
flaskapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, jsonify, redirect, render_template, request, url_for
from plyer import notification
app = Flask(__name__)
@app.route("/toast", methods=["GET", "POST"])
def make_toast():
if request.method == "GET":
return redirect(url_for("index"))
data = request.form
title, message = data["title"], data["message"]
message = data["message"]
if title == "":
title = "Missing title"
if message == "":
message = "Missing message"
notify(message, title)
success = True
return jsonify({"success": success, "title": title, "message": message})
def notify(message, title):
notification.notify(
title=title,
message=message,
timeout=100,
)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)