-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.py
63 lines (44 loc) · 1.05 KB
/
site.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'''
Created on Oct 25, 2013
@author: George Lifchits
'''
from flask import Flask
from flask import render_template, request
import json
from ituneslib import iTunes
app = Flask(__name__)
app.debug = True
log = app.logger
SUCC = 'success'
@app.route('/')
def home():
return render_template('home.html')
@app.route('/toggle', methods = ['POST'])
def toggle():
itunes = iTunes()
itunes.toggle()
return SUCC
@app.route('/next', methods = ['POST'])
def next_song():
itunes = iTunes()
itunes.next()
return SUCC
@app.route('/prev', methods = ['POST'])
def prev_song():
itunes = iTunes()
itunes.prev()
return SUCC
@app.route('/get_song')
def get_song():
itunes = iTunes()
info = itunes.current_track()
return json.dumps(info)
@app.route('/set_rating', methods = ['POST'])
def set_rating():
rating = request.values.get('rating')
log.info ('rating is %s' % rating)
itunes = iTunes()
itunes.set_rating(rating)
return str(request.values)
if __name__ == "__main__":
app.run(host = '0.0.0.0')