From 050be9d4f67795f3ed2f8b804cbc26f70682b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Mon, 17 Jul 2017 11:46:58 +0200 Subject: [PATCH] Add WSGI deployment files for Apache --- apache/010-soundboard.conf | 15 +++++++++++++++ soundboard.py | 3 ++- soundboard.wsgi | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 apache/010-soundboard.conf create mode 100644 soundboard.wsgi diff --git a/apache/010-soundboard.conf b/apache/010-soundboard.conf new file mode 100644 index 0000000..84372a9 --- /dev/null +++ b/apache/010-soundboard.conf @@ -0,0 +1,15 @@ +Listen 5000 + + #ServerName example.com + + WSGIDaemonProcess soundboard user=www-data group=www-data threads=5 + WSGIScriptAlias / /var/www/soundboard/soundboard.wsgi + + + WSGIProcessGroup soundboard + WSGIApplicationGroup %{GLOBAL} + WSGIScriptReloading On + Order deny,allow + Allow from all + + diff --git a/soundboard.py b/soundboard.py index 76e5956..4531992 100644 --- a/soundboard.py +++ b/soundboard.py @@ -18,7 +18,8 @@ processlist = [] @app.route("/say/", methods=["POST"]) @app.route("/say/") def index(sound=None, text=None, video=None): - sounds = sorted(os.listdir(config.path)) + sounds = [os.fsencode(file).decode() for file in os.listdir(config.path)] + sounds = sorted(sounds) if sound is not None and sound in sounds: subprocess.Popen(["omxplayer", os.path.join(config.path, sound)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) diff --git a/soundboard.wsgi b/soundboard.wsgi new file mode 100644 index 0000000..dffa811 --- /dev/null +++ b/soundboard.wsgi @@ -0,0 +1,10 @@ +import sys + +sys.path.insert(0, '/var/www/soundboard') + +activate_this = '/var/www/soundboard/py/bin/activate_this.py' + +with open(activate_this) as file_: + exec(file_.read(), dict(__file__=activate_this)) + +from soundboard import app as application