mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-06-14 14:34:45 +02:00
je tente des truc mais on a jamais été si proche
This commit is contained in:
28
Flask/app.py
28
Flask/app.py
@ -12,18 +12,18 @@ import json
|
||||
import re
|
||||
from requests import get
|
||||
import redis
|
||||
from flask_sse import sse
|
||||
|
||||
|
||||
# redis part for live update
|
||||
redis_client = redis.StrictRedis(host='127.0.0.1', port=6379, db=0)
|
||||
pubsub = redis_client.pubsub()
|
||||
pubsub.subscribe('console')
|
||||
|
||||
def generate_output():
|
||||
for message in pubsub.listen():
|
||||
if message['type'] == 'message':
|
||||
print(message)
|
||||
yield f"data: {message['data'].decode()}\n\n"
|
||||
## redis part for live update
|
||||
#redis_client = redis.StrictRedis(host='127.0.0.1', port=6379, db=0)
|
||||
#pubsub = redis_client.pubsub()
|
||||
#pubsub.subscribe('console')
|
||||
#
|
||||
#def generate_output():
|
||||
# for message in pubsub.listen():
|
||||
# if message['type'] == 'message':
|
||||
# print(message)
|
||||
# yield f"data: {message['data'].decode()}\n\n"
|
||||
|
||||
|
||||
# the end
|
||||
@ -124,6 +124,7 @@ def inject_default_variables():
|
||||
#Login stuff
|
||||
"""
|
||||
# config
|
||||
app.config["REDIS_URL"] = "redis://localhost"
|
||||
app.config["TEMPLATES_AUTO_RELOAD"] = True
|
||||
app.config.update(
|
||||
SECRET_KEY = secret
|
||||
@ -145,9 +146,8 @@ class User(UserMixin):
|
||||
|
||||
users = [User(1)]
|
||||
|
||||
@app.route('/stream')
|
||||
def stream():
|
||||
return Response(generate_output(), content_type='text/event-stream')
|
||||
|
||||
app.register_blueprint(sse, url_prefix='/stream')
|
||||
|
||||
|
||||
@app.route("/login/", methods=["GET", "POST"])
|
||||
|
Reference in New Issue
Block a user