Esempio n. 1
0
@route('/do/<command>/')
def play(command):
    status = request.mpd.status().get( 'state', '')
    if command == 'play':
        request.mpd.pause() if status == 'play' else request.mpd.play()
    elif command == 'next':
        request.mpd.next()
    elif command == 'prev':
        request.mpd.previous()
    elif command == 'stop':
        request.mpd.stop()
    return redirect('/')
    
@route('/static/<filename:path>')
def send_static(filename):
    return static_file(filename, root=os.path.join(BASE_DIR, 'static'))

if __name__ == '__main__':
    Song.initialize()
    c = MPDClient()
    c.connect("localhost", 6600)
    for s in c.listallinfo():
        try:
            song = Song(**s)
        except Exception as e:
            print(e, s)
        else:
            song.save() 
    
    run(host='localhost', port=8080, reloader=True, debug=True)