-1

I have script which executes for 10 minutes and generates logs/outputs while executing..i want these logs to be passed to html file using flask.

Rajesh s
  • 175
  • 1
  • 8

1 Answers1

3
  1. You can use ajax methods in your javascript code to ask server for new logs/outputs with any period.
  2. You can open WebSocket and write your logs to client in real-time. Look at example on flask-socketIO documentation: https://flask-socketio.readthedocs.io/en/latest/ or somewhere else. Here is example how to send message to client:
from flask import Flask, render_template
from flask_socketio import SocketIO, send

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

@socketio.on('message')
def handle_message(message):
    send(message)

if __name__ == '__main__':
    socketio.run(app)
AmaHacka
  • 104
  • 6