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.
Asked
Active
Viewed 844 times
-1
-
3what is the problem ? what have you tried ? do you mean *continuously* as in real-time or as in *periodically* ? – Mar 29 '19 at 15:47
-
Please provide a [mcve] – Pitto Mar 29 '19 at 16:08
-
I mean the data-should be updated in real time. – Rajesh s Mar 30 '19 at 05:05
1 Answers
3
- You can use ajax methods in your javascript code to ask server for new logs/outputs with any period.
- 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
-
Can you give me an example how to use ajax to ask server for new logs/outputs. – Rajesh s Mar 31 '19 at 02:23
-
Check out first answer in original question. There you can find an example. – AmaHacka Apr 01 '19 at 10:25