Compare commits

...

3 Commits

Author SHA1 Message Date
603d178d03 versioning
Some checks failed
Build and Publish Docker Image / build-and-push (push) Failing after 44s
2025-07-13 16:04:57 +01:00
30918daeb4 lots of rework for autocomplete 2025-07-13 16:00:52 +01:00
09293b5cf2 Fixed getstreamnames request 2025-07-13 15:45:12 +01:00
11 changed files with 76 additions and 19 deletions

24
.vscode/launch.json vendored
View File

@ -1,17 +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 Debugger: Current File",
"name": "Python: Flask",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
"args": ["--host=0.0.0.0"]
"module": "flask",
"env": {
"FLASK_APP": "app.py",
"FLASK_ENV": "development"
},
"args": [
"run",
"--no-debugger",
"--port",
"5005",
"--host",
"0.0.0.0"
],
"jinja": true,
"justMyCode": true
}
]
}

1
VERSION Normal file
View File

@ -0,0 +1 @@
1.0.6

13
app.py
View File

@ -9,23 +9,26 @@ from flask import send_from_directory
import requests
import base64
from flask import Flask
from config import DevelopmentConfig
from config import DevelopmentConfig, ProductionConfig
from paddleocr import PaddleOCR
from PIL import Image
import numpy as np
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
app = Flask(__name__)
app.config.from_object(
DevelopmentConfig
)
if os.environ.get("FLASK_ENV") == "production":
app.config.from_object(ProductionConfig)
else:
app.config.from_object(DevelopmentConfig)
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
app.config['SESSION_COOKIE_SECURE'] = True # Only send cookie over HTTPS
app.config["SESSION_COOKIE_SECURE"] = not app.config["DEBUG"]
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests
app.config['PERMANENT_SESSION_LIFETIME'] = 60 * 60 * 24 * 365 # 1 year in seconds

View File

@ -17,9 +17,12 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN chmod +x run.sh
ARG VERSION
RUN echo $VERSION > VERSION
EXPOSE 8089
EXPOSE 5000
CMD ["python", "app.py"]
ENV FLASK_ENV production
CMD ["./run.sh"]

10
gunicorn.conf.py Normal file
View File

@ -0,0 +1,10 @@
import os
# Set the environment to production
os.environ['FLASK_ENV'] = 'production'
# Gunicorn config variables
loglevel = "info"
workers = 2
bind = "0.0.0.0:5000"
timeout = 120

View File

@ -118,6 +118,12 @@ def get_stream_names(base_url: str, auth: str) -> List[str]:
List[str]: A list of stream names.
"""
url = f"{base_url}/getStreamNames"
payload = {}
headers = {"Authorization": f"Basic {auth}"}
response = requests.get(url, headers=headers)
return json.loads(response.text)
response = requests.request("GET", url, headers=headers, data=payload)
if response.status_code == 200 and response.text:
try:
return json.loads(response.text)
except json.JSONDecodeError:
return []
return []

8
pyproject.toml Normal file
View File

@ -0,0 +1,8 @@
[tool.bump-my-version]
current_version = "1.0.6"
commit = true
tag = true
message = "bump version to {new_version}"
[[tool.bump-my-version.files]]
filename = "VERSION"

Binary file not shown.

12
run.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Default to development environment
FLASK_ENV=${FLASK_ENV:-development}
if [ "$FLASK_ENV" = "production" ]; then
echo "Starting in production mode..."
gunicorn --config gunicorn.conf.py app:app
else
echo "Starting in development mode..."
python3 app.py
fi

View File

@ -28,3 +28,9 @@ footer {
text-align: center;
padding: 1em;
}
/* Awesomplete and Bootstrap integration fix */
div.awesomplete {
display: block;
width: 100%;
}

View File

@ -75,7 +75,7 @@
</button>
</form>
<hr>
<h4>Load Details Via OCR</h2>
<h2>Load Details Via OCR</h2>
<form action="/OCRupload" method="POST" enctype="multipart/form-data" onsubmit="showLoadingOCR()">
<div class="form-group">
<label for="image">Select Image</label>
@ -110,7 +110,7 @@
.then(response => response.json())
.then(data => {
new Awesomplete(streamInput, {
list: data.map(item => item.streamName)
list: data
});
});
});