Atualizar app/app.py
This commit is contained in:
+16
@@ -10,6 +10,8 @@ from markdown import markdown
|
|||||||
from config import Config
|
from config import Config
|
||||||
from models import Base, Conversation, Message, Attachment
|
from models import Base, Conversation, Message, Attachment
|
||||||
|
|
||||||
|
from flask_sock import Sock
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(Config)
|
app.config.from_object(Config)
|
||||||
app.secret_key = app.config["SECRET_KEY"]
|
app.secret_key = app.config["SECRET_KEY"]
|
||||||
@@ -20,6 +22,20 @@ Base.metadata.create_all(engine)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sock = Sock(app)
|
||||||
|
|
||||||
|
@sock.route("/ws/notifications")
|
||||||
|
def notifications(ws):
|
||||||
|
# All comments are in English.
|
||||||
|
# Simple example: send a ping every time a message is added.
|
||||||
|
while True:
|
||||||
|
data = ws.receive()
|
||||||
|
# You can interpret data or just echo.
|
||||||
|
ws.send(json.dumps({"type": "pong", "payload": data}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def require_capability(cap):
|
def require_capability(cap):
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user