Move path to external file

This commit is contained in:
Martin Müller 2017-07-13 22:53:29 +02:00
parent 3391c7e076
commit 838881a1b3
2 changed files with 3 additions and 2 deletions

1
config.py.example Normal file
View File

@ -0,0 +1 @@
path = "/home/pi/sounds"

View File

@ -5,7 +5,7 @@ import subprocess
from flask import Flask, render_template, request, redirect, url_for from flask import Flask, render_template, request, redirect, url_for
path = "/home/pi/sounds" import config
app = Flask(__name__) app = Flask(__name__)
app.jinja_env.trim_blocks = True app.jinja_env.trim_blocks = True
@ -16,7 +16,7 @@ app.jinja_env.lstrip_blocks = True
@app.route("/say/", methods=["POST"]) @app.route("/say/", methods=["POST"])
@app.route("/say/<text>") @app.route("/say/<text>")
def index(sound=None, text=None, video=None): 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: if sound is not None and sound in sounds:
subprocess.Popen(["omxplayer", os.path.join(path, sound)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.Popen(["omxplayer", os.path.join(path, sound)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)