mirror of
https://github.com/PhoenixTwoFive/karaoqueue.git
synced 2025-05-20 03:21:47 +02:00
Send more data to the frontend
This commit is contained in:
parent
ca3d5f8a77
commit
869166f818
25
backend/.vscode/launch.json
vendored
Normal file
25
backend/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Flask",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "flask",
|
||||
"env": {
|
||||
"FLASK_APP": "app/main.py",
|
||||
"FLASK_ENV": "development",
|
||||
"FLASK_DEBUG": "0"
|
||||
},
|
||||
"args": [
|
||||
"run",
|
||||
"--no-debugger",
|
||||
"--no-reload"
|
||||
],
|
||||
"jinja": true
|
||||
}
|
||||
]
|
||||
}
|
3
backend/.vscode/settings.json
vendored
Normal file
3
backend/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.pythonPath": "/usr/bin/python3.8"
|
||||
}
|
@ -9,6 +9,13 @@ entry_table = "entries"
|
||||
index_label = "Id"
|
||||
done_table = "done_songs"
|
||||
|
||||
|
||||
def dict_factory(cursor, row):
|
||||
d = {}
|
||||
for idx, col in enumerate(cursor.description):
|
||||
d[col[0]] = row[idx]
|
||||
return d
|
||||
|
||||
def open_db():
|
||||
conn = sqlite3.connect("data/test.db")
|
||||
conn.execute('PRAGMA encoding = "UTF-8";')
|
||||
@ -94,12 +101,13 @@ def get_song_list():
|
||||
|
||||
def get_song_completions(input_string):
|
||||
conn = open_db()
|
||||
conn.row_factory = dict_factory
|
||||
cur = conn.cursor()
|
||||
# Don't look, it burns...
|
||||
prepared_string = "%{0}%".format(input_string).upper() # "Test" -> "%TEST%"
|
||||
print(prepared_string)
|
||||
cur.execute(
|
||||
"SELECT Title || \" - \" || Artist AS Song, Id FROM songs WHERE REPLACE(REPLACE(REPLACE(REPLACE(UPPER( SONG ),'ö','Ö'),'ü','Ü'),'ä','Ä'),'ß','ẞ') LIKE (?) LIMIT 20;", (prepared_string,))
|
||||
"SELECT * FROM songs WHERE REPLACE(REPLACE(REPLACE(REPLACE(UPPER( Title ),'ö','Ö'),'ü','Ü'),'ä','Ä'),'ß','ẞ') LIKE (?) LIMIT 20;", (prepared_string,))
|
||||
return cur.fetchall()
|
||||
|
||||
def add_entry(name,song_id):
|
||||
|
@ -1,4 +1,5 @@
|
||||
from flask import Flask, render_template, Response, abort, request, redirect
|
||||
from flask_cors import CORS
|
||||
import helpers
|
||||
import database
|
||||
import data_adapters
|
||||
@ -7,6 +8,7 @@ import json
|
||||
from flask_basicauth import BasicAuth
|
||||
app = Flask(__name__, static_url_path='/static')
|
||||
|
||||
CORS(app)
|
||||
basic_auth = BasicAuth(app)
|
||||
accept_entries = False
|
||||
|
||||
@ -65,7 +67,8 @@ def get_song_completions(input_string=""):
|
||||
if input_string!="":
|
||||
print(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')
|
||||
return Response(json.dumps(list).encode('utf-8'), mimetype='application/json')
|
||||
# return Response(json.dumps(list, ensure_ascii=False).encode('utf-8'), mimetype='text/json')
|
||||
|
||||
else:
|
||||
return 400
|
||||
|
Loading…
x
Reference in New Issue
Block a user