From 6d91b6e4919a1688b1f0743b6a9c8d60ecae94a4 Mon Sep 17 00:00:00 2001 From: piair Date: Mon, 2 Oct 2023 23:19:17 +0200 Subject: [PATCH] je comprend pas pk ca marche pas --- Flask/app.py | 36 +++++++++++++++--------------------- Flask/templates/dev.html | 1 + 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Flask/app.py b/Flask/app.py index 061853f..a0e32ee 100644 --- a/Flask/app.py +++ b/Flask/app.py @@ -1,3 +1,5 @@ +import gevent.monkey +gevent.monkey.patch_all() from time import sleep import subprocess import os @@ -9,6 +11,8 @@ from werkzeug.utils import secure_filename import json import re from requests import get +import redis + # redis part for live update redis_client = redis.StrictRedis(host='localhost', port=6379, db=0) @@ -16,13 +20,13 @@ pubsub = redis_client.pubsub() pubsub.subscribe('console') def generate_output(): - for message in pubsub.listen(): - if message['type'] == 'message': - yield f"data: {message['data'].decode()}\n\n" + try: + for message in pubsub.listen(): + if message['type'] == 'message': + yield f"data: {message['data'].decode()}\n\n" + except redis.exceptions.ConnectionError as e: + print(f"Error connecting to Redis: {e}") -@app.route('/stream') -def stream(): - return Response(generate_output(), content_type='text/event-stream') # end global password @@ -142,6 +146,11 @@ class User(UserMixin): users = [User(1)] +@app.route('/stream') +def stream(): + return Response(generate_output(), content_type='text/event-stream') + + @app.route("/login/", methods=["GET", "POST"]) def login(): if request.method == 'POST': @@ -232,21 +241,6 @@ def discord_post(): @app.route("/dev/") def dev2(): - with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile: - j = json.load(inFile) - new_proxy = {"address": "ADDRESS", "port": "PORT", "name":"NAME"} - max_index = 0 - for i in range(1, 50): - try : - print(j[str(i)]) - except : - print(f"found {i - 1} proxys") - max_index = i - break - j[f"{max_index}"] = new_proxy - print(j) - with open("/app/MsRewards-Reborn/user_data/proxy.json", "w") as outfile: - json.dump(j, outfile) return(render_template("dev.html")) diff --git a/Flask/templates/dev.html b/Flask/templates/dev.html index ec30bfb..085a2c1 100644 --- a/Flask/templates/dev.html +++ b/Flask/templates/dev.html @@ -20,6 +20,7 @@ const eventSource = new EventSource('/stream'); eventSource.onmessage = (event) => { + console.log("etqhbbqetbqedrtqberzegr"); const newOutput = document.createElement('div'); newOutput.textContent = event.data; consoleElement.appendChild(newOutput);