auto complete steam names
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 3m7s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 3m7s
This commit is contained in:
parent
73134ae883
commit
5b0243ab93
11
app.py
11
app.py
@ -4,7 +4,7 @@ from flask_caching import Cache
|
||||
import requests.auth
|
||||
import os
|
||||
from lib.datetime import filter_accounts_next_30_days, filter_accounts_expired
|
||||
from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_user_accounts_count
|
||||
from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_user_accounts_count, get_stream_names
|
||||
from flask import send_from_directory
|
||||
import requests
|
||||
import base64
|
||||
@ -164,6 +164,15 @@ def delete_account():
|
||||
return redirect(url_for("user_accounts"))
|
||||
|
||||
|
||||
@app.route("/get_stream_names", methods=["GET"])
|
||||
def stream_names():
|
||||
if not session.get("logged_in"):
|
||||
return redirect(url_for("home"))
|
||||
base_url = app.config["BASE_URL"]
|
||||
stream_names = get_stream_names(base_url, session["auth_credentials"])
|
||||
return jsonify(stream_names)
|
||||
|
||||
|
||||
@app.route('/OCRupload', methods=['POST'])
|
||||
def OCRupload():
|
||||
if 'image' not in request.files:
|
||||
|
16
lib/reqs.py
16
lib/reqs.py
@ -105,3 +105,19 @@ def get_user_accounts_count(base_url: str, auth: str) -> int:
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
res_json = json.loads(response.text)
|
||||
return res_json['count']
|
||||
|
||||
|
||||
def get_stream_names(base_url: str, auth: str) -> List[str]:
|
||||
"""Get a list of stream names from the API.
|
||||
|
||||
Args:
|
||||
base_url (str): The base URL of the API.
|
||||
auth (str): The authorization token.
|
||||
|
||||
Returns:
|
||||
List[str]: A list of stream names.
|
||||
"""
|
||||
url = f"{base_url}/getStreamNames"
|
||||
headers = {"Authorization": f"Basic {auth}"}
|
||||
response = requests.get(url, headers=headers)
|
||||
return json.loads(response.text)
|
||||
|
@ -7,6 +7,7 @@
|
||||
<title>Add Account - KTVManager</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" />
|
||||
<style>
|
||||
/* Hide the spinner by default */
|
||||
#loadingSpinner,
|
||||
@ -90,6 +91,7 @@
|
||||
<footer class="bg-dark text-white text-center py-3 mt-5">
|
||||
<p></p>
|
||||
</footer>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js"></script>
|
||||
<script>
|
||||
function showLoading() {
|
||||
document.getElementById("submitButton").disabled = true;
|
||||
@ -101,6 +103,17 @@
|
||||
document.getElementById("ocrLoadingSpinner").style.display = "inline-block";
|
||||
document.getElementById("ocrButtonText").textContent = "Processing...";
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var streamInput = document.getElementById("stream");
|
||||
var awesomplete = new Awesomplete(streamInput);
|
||||
|
||||
fetch('/get_stream_names')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
awesomplete.list = data.map(item => item.streamName);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user