From 838881a1b3f0e3a170ce9f335384c837a3c27327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Thu, 13 Jul 2017 22:53:29 +0200 Subject: [PATCH] Move path to external file --- config.py.example | 1 + soundboard.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 config.py.example diff --git a/config.py.example b/config.py.example new file mode 100644 index 0000000..841b7df --- /dev/null +++ b/config.py.example @@ -0,0 +1 @@ +path = "/home/pi/sounds" diff --git a/soundboard.py b/soundboard.py index a501310..3299973 100644 --- a/soundboard.py +++ b/soundboard.py @@ -5,7 +5,7 @@ import subprocess from flask import Flask, render_template, request, redirect, url_for -path = "/home/pi/sounds" +import config app = Flask(__name__) app.jinja_env.trim_blocks = True @@ -16,7 +16,7 @@ app.jinja_env.lstrip_blocks = True @app.route("/say/", methods=["POST"]) @app.route("/say/") def index(sound=None, text=None, video=None): - sounds = sorted(os.listdir(path)) + sounds = sorted(os.listdir(config.path)) if sound is not None and sound in sounds: subprocess.Popen(["omxplayer", os.path.join(path, sound)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)