2020-01-21 08:34:15 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
|
|
|
|
|
|
|
SSE API for node client access
|
|
|
|
"""
|
2020-06-20 10:31:51 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
2020-01-14 08:29:42 +00:00
|
|
|
from flask import g, Blueprint
|
|
|
|
from gevent import sleep
|
2020-01-28 05:52:35 +00:00
|
|
|
import gevent
|
2020-06-20 10:31:51 +00:00
|
|
|
import ujson
|
2020-01-14 08:29:42 +00:00
|
|
|
|
2020-06-20 10:31:51 +00:00
|
|
|
from onionrutils.epoch import get_epoch
|
2020-01-14 08:29:42 +00:00
|
|
|
from .. import wrapper
|
2020-01-21 08:34:15 +00:00
|
|
|
"""
|
2022-03-18 00:56:31 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-01-21 08:34:15 +00:00
|
|
|
"""
|
2020-01-14 08:29:42 +00:00
|
|
|
|
|
|
|
private_sse_blueprint = Blueprint('privatesse', __name__)
|
|
|
|
SSEWrapper = wrapper.SSEWrapper()
|
|
|
|
|
2020-01-28 05:52:35 +00:00
|
|
|
gevent.hub.Hub.NOT_ERROR = (gevent.GreenletExit, SystemExit, Exception)
|
2020-01-14 08:29:42 +00:00
|
|
|
|
|
|
|
@private_sse_blueprint.route('/hello')
|
2020-01-21 08:34:15 +00:00
|
|
|
def stream_hello():
|
2020-01-14 08:29:42 +00:00
|
|
|
def print_hello():
|
|
|
|
while True:
|
|
|
|
yield "hello\n\n"
|
|
|
|
sleep(1)
|
|
|
|
return SSEWrapper.handle_sse_request(print_hello)
|
2020-01-21 08:34:15 +00:00
|
|
|
|