diff --git a/libresign/flaskapp.py b/libresign/flaskapp.py index a44a621..2e42ec4 100644 --- a/libresign/flaskapp.py +++ b/libresign/flaskapp.py @@ -19,10 +19,15 @@ from flask import Flask, request, render_template, redirect, send_file import libresign.config as config -import libresign.web as web from libresign.request import Request app = Flask(__name__) +web = None + +def run (web_): + global web + web = web_ + app.run(debug=True, use_reloader=False, threaded=True, port=config.HTTP_PORT, host="0.0.0.0") # in case we want to add some more bells and whistles def file_request (request_type): diff --git a/libresign/web.py b/libresign/web.py index 9319199..36392af 100644 --- a/libresign/web.py +++ b/libresign/web.py @@ -50,15 +50,19 @@ def stop(): # TODO use other server than werkzeug and deal with shutdown at that point pass +class WebPusher(): + def push_request (self, request): + global msg_queue + + if msg_queue: + msg_queue.put(request) + def web_thread(): + web = WebPusher() logging.info("starting web server") - flaskapp.app.run(debug=True, use_reloader=False, threaded=True, port=config.HTTP_PORT, host="0.0.0.0") + flaskapp.run(web) logging.info("stopping web server") -def push_request (request): - if msg_queue: - msg_queue.put(request) - def get_playlist (): playlist = signd.get_playlist() return playlist.playlist