mirror of
https://github.com/PhoenixTwoFive/karaoqueue.git
synced 2025-12-15 21:21:56 +01:00
Add nice frontend, Add song search, add enqueueing
This commit is contained in:
37
main.py
37
main.py
@@ -1,18 +1,37 @@
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, Response, abort, request
|
||||
import helpers
|
||||
import database
|
||||
import os, errno
|
||||
app = Flask(__name__)
|
||||
import json
|
||||
app = Flask(__name__, static_url_path='/static')
|
||||
@app.route("/")
|
||||
def home():
|
||||
return render_template('index.html', list=database.get_list())
|
||||
return render_template('main.html', list=database.get_list())
|
||||
|
||||
@app.route('/api/enqueue', methods=['POST'])
|
||||
def enqueue():
|
||||
if not request.json:
|
||||
print(request.data)
|
||||
abort(400)
|
||||
name = request.json['name']
|
||||
song_id = request.json['id']
|
||||
database.add_entry(name,song_id)
|
||||
return "OK"
|
||||
|
||||
@app.route("/list")
|
||||
def index():
|
||||
list = database.get_list()
|
||||
for entry in list:
|
||||
print(entry[0])
|
||||
return str(database.get_list())
|
||||
def songlist():
|
||||
return render_template('songlist.html', list=database.get_song_list())
|
||||
|
||||
@app.route("/api/songs")
|
||||
def songs():
|
||||
list = database.get_song_list()
|
||||
return Response(json.dumps(list, ensure_ascii=False).encode('utf-8'), mimetype='text/json')
|
||||
|
||||
|
||||
@app.route("/api/songs/compl/<input_string>")
|
||||
def get_song_completions(input_string):
|
||||
list = database.get_song_completions(input_string=input_string)
|
||||
return Response(json.dumps(list, ensure_ascii=False).encode('utf-8'), mimetype='text/json')
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""try:
|
||||
@@ -24,4 +43,4 @@ if __name__ == "__main__":
|
||||
database.create_entry_table()
|
||||
database.create_list_view()
|
||||
database.import_songs(helpers.get_songs(helpers.get_catalog_url()))
|
||||
app.run(debug=True)
|
||||
app.run(debug=True, host='0.0.0.0')
|
||||
|
||||
Reference in New Issue
Block a user