Commit 63f2bdc8 authored by Andre Julius's avatar Andre Julius 👀
Browse files

Remove unnecessary imports in views.py. Improve and add further documentation in views.py

parent 627a9394
from flask import redirect, abort, request, jsonify, Response, make_response
from flask import redirect, abort, jsonify
from web import web
import api.index
import api.player
......@@ -12,7 +12,7 @@ logger = logging.getLogger("queue")
@web.route('/', defaults={'path': ''})
@web.route('/<path:path>')
def catch_all(path):
""" Catches all requests that are not handled by any other method """
""" Catch all requests that are not handled by any other method """
return redirect("/")
......@@ -20,12 +20,21 @@ def catch_all(path):
@web.route("/")
@web.route("/index/")
def index():
""" Return a list of all available sound files as a json array.
The list is refreshed with each request. """
api.index.reload_index()
return jsonify(api.index.index)
@web.route("/play/<file>")
def play(file):
""" Try enqueing a song. If given file name can not be found in the index,
return 404 not found. If the queue is full drop the request and return
403 not allowed as you may not enque any further songs at this time.
If queing is successfull return the position in the queue. Play the
oldest song in the queue. """
if api.index.is_indexed(file):
try:
api.queue.q.put(file, False)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment