-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathmain.py
55 lines (36 loc) · 1.02 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = "ipetrash"
import logging
import threading
import sys
from pathlib import Path
from flask import Flask, request, redirect
ROOT = Path(__file__).resolve().parent.parent.parent
sys.path.append(
str(ROOT / "winapi__windows__ctypes/windows__toast_balloontip_notifications")
)
from run_notify import run_in_thread
app = Flask(__name__)
logging.basicConfig(level=logging.DEBUG)
def show(text):
title = str(threading.current_thread())
run_in_thread(title, text, duration=20)
@app.route("/")
def index():
return redirect("/show_notification?text=О, уведомление пришло!")
@app.route("/show_notification")
def show_notification():
text = request.args.get("text")
print("text:", text)
# Run function in new thread
thread = threading.Thread(target=show, args=(text,))
thread.start()
return "Ok"
if __name__ == "__main__":
# Localhost
app.run(
port=5000,
)
# # Public IP
# app.run(host='0.0.0.0')