Commit 07e650b8 authored by Andre Julius's avatar Andre Julius 👀
Browse files

Enque items based on http request. Return error codes when queue full

parent cc75c7b6
import logging
from api.player import player
from web import web
from api.index import reload_index
reload_index()
web.run(debug=True, host="0.0.0.0", port=80)
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)-5s %(name)-18s %(message)s',
datefmt='%y-%m-%d %H:%M'
)
player.start()
web.run(debug=True, host="0.0.0.0", port=80)
\ No newline at end of file
......@@ -2,6 +2,11 @@ from flask import redirect, abort, request, jsonify, Response
from web import web
import api.index
import api.player
import api.queue
import logging
from queue import Full
logger = logging.getLogger("queue")
@web.route('/', defaults={'path': ''})
......@@ -21,7 +26,11 @@ def index():
@web.route("/play/<file>")
def play(file):
if api.index.is_indexed(file):
api.player.play(file)
try:
api.queue.q.put(file, False)
logger.info(api.queue.q.qsize())
except Full:
return abort(403)
return Response(200)
else:
return abort(404)
return "done"
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