-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflaskController.py
36 lines (29 loc) · 1000 Bytes
/
flaskController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask, render_template
import plexController as pc
import request
app = Flask(__name__)
myplayablemedias = []
@app.route("/")
def displaymedia():
mymedias = pc.findplayingmedia()
for mediainfo in mymedias:
if mediainfo['convert']:
myplayablemedias.append(mediainfo)
else:
print ("this was a music track")
return render_template("home.html", posts = myplayablemedias)
@app.route("/execute/<mediaid>")
def executesave(mediaid):
#do your things here
mediaidmatch = (item for item in myplayablemedias if item["id"] == mediaid).next()
pc.createvideo(mediaidmatch['path'], mediaidmatch['playhead'])
return (mediaidmatch["title"] + " is being rendered out. Check Dropbox.")
@app.route('/rest')
def rest_live():
live_medias = pc.findplayingmedia()
return (jsonify(live_medias))
@app.route('/hello')
def hello():
return 'Hello, World'
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)