from flask import Flask, render_template, jsonify
from redis import Redis
from utils.database import DB as db

import os
import requests

import logging
_logger = logging.getLogger(__name__)

TEMPLATE_DIR = os.path.abspath('./templates')
STATIC_DIR = os.path.abspath('./static')

app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR)
redis = Redis(host='redis', port=6379)


@app.route('/api/artists')
def api_artists():
    return jsonify(db.get_all('artists'))


@app.route('/api/queue')
def api_queue():
    return jsonify(db.get_all('albums', where="done != true"))


@app.route('/')
def index():
    return render_template('app.html')


if __name__ == "__main__":
    print('Starting App...')
    app.run(host="0.0.0.0", debug=True)
