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 requests.auth
|
||||||
import os
|
import os
|
||||||
from lib.datetime import filter_accounts_next_30_days, filter_accounts_expired
|
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
|
from flask import send_from_directory
|
||||||
import requests
|
import requests
|
||||||
import base64
|
import base64
|
||||||
@ -164,6 +164,15 @@ def delete_account():
|
|||||||
return redirect(url_for("user_accounts"))
|
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'])
|
@app.route('/OCRupload', methods=['POST'])
|
||||||
def OCRupload():
|
def OCRupload():
|
||||||
if 'image' not in request.files:
|
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)
|
response = requests.request("GET", url, headers=headers, data=payload)
|
||||||
res_json = json.loads(response.text)
|
res_json = json.loads(response.text)
|
||||||
return res_json['count']
|
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>
|
<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="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="{{ url_for('static', filename='styles.css') }}" />
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" />
|
||||||
<style>
|
<style>
|
||||||
/* Hide the spinner by default */
|
/* Hide the spinner by default */
|
||||||
#loadingSpinner,
|
#loadingSpinner,
|
||||||
@ -90,6 +91,7 @@
|
|||||||
<footer class="bg-dark text-white text-center py-3 mt-5">
|
<footer class="bg-dark text-white text-center py-3 mt-5">
|
||||||
<p></p>
|
<p></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function showLoading() {
|
function showLoading() {
|
||||||
document.getElementById("submitButton").disabled = true;
|
document.getElementById("submitButton").disabled = true;
|
||||||
@ -101,6 +103,17 @@
|
|||||||
document.getElementById("ocrLoadingSpinner").style.display = "inline-block";
|
document.getElementById("ocrLoadingSpinner").style.display = "inline-block";
|
||||||
document.getElementById("ocrButtonText").textContent = "Processing...";
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user