Esempio n. 1
0
import atexit
from flask import Flask
from flask import Response
from flask import render_template
from flask import stream_with_context

from shell_command import ShellCommand

APP = Flask(__name__)

LOOP = asyncio.get_event_loop()
asyncio.set_event_loop(LOOP)
atexit.register(LOOP.close)
cmd = ShellCommand('tail', '/var/log/syslog')
cmd.execute()


@APP.route('/shell')
def shell():
    def events():
        ll = []

        def handler(item):
            ll.append(item)

        cmd = ShellCommand('tail', '/var/log/syslog')

        yield 'event: ping\n'
        yield 'data: Executing "{}"\n\n'.format(cmd)