Compare commits
No commits in common. "603d178d033bbad2de8ad0985c170bde0f8f5668" and "dbb1eb7b1713582e81fc32c82804109649a5f006" have entirely different histories.
603d178d03
...
dbb1eb7b17
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -1,25 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
// 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",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Python: Flask",
|
"name": "Python Debugger: Current File",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "flask",
|
"program": "${file}",
|
||||||
"env": {
|
"console": "integratedTerminal",
|
||||||
"FLASK_APP": "app.py",
|
"justMyCode": false,
|
||||||
"FLASK_ENV": "development"
|
"args": ["--host=0.0.0.0"]
|
||||||
},
|
|
||||||
"args": [
|
|
||||||
"run",
|
|
||||||
"--no-debugger",
|
|
||||||
"--port",
|
|
||||||
"5005",
|
|
||||||
"--host",
|
|
||||||
"0.0.0.0"
|
|
||||||
],
|
|
||||||
"jinja": true,
|
|
||||||
"justMyCode": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
13
app.py
13
app.py
@ -9,26 +9,23 @@ from flask import send_from_directory
|
|||||||
import requests
|
import requests
|
||||||
import base64
|
import base64
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from config import DevelopmentConfig, ProductionConfig
|
from config import DevelopmentConfig
|
||||||
from paddleocr import PaddleOCR
|
from paddleocr import PaddleOCR
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
os.environ["OMP_NUM_THREADS"] = "1"
|
os.environ["OMP_NUM_THREADS"] = "1"
|
||||||
os.environ["MKL_NUM_THREADS"] = "1"
|
os.environ["MKL_NUM_THREADS"] = "1"
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(
|
||||||
if os.environ.get("FLASK_ENV") == "production":
|
DevelopmentConfig
|
||||||
app.config.from_object(ProductionConfig)
|
)
|
||||||
else:
|
|
||||||
app.config.from_object(DevelopmentConfig)
|
|
||||||
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
||||||
|
|
||||||
ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
||||||
|
|
||||||
app.config["SESSION_COOKIE_SECURE"] = not app.config["DEBUG"]
|
app.config['SESSION_COOKIE_SECURE'] = True # Only send cookie over HTTPS
|
||||||
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
||||||
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests
|
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests
|
||||||
app.config['PERMANENT_SESSION_LIFETIME'] = 60 * 60 * 24 * 365 # 1 year in seconds
|
app.config['PERMANENT_SESSION_LIFETIME'] = 60 * 60 * 24 * 365 # 1 year in seconds
|
||||||
|
@ -17,12 +17,9 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN chmod +x run.sh
|
|
||||||
|
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
RUN echo $VERSION > VERSION
|
RUN echo $VERSION > VERSION
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 8089
|
||||||
|
|
||||||
ENV FLASK_ENV production
|
CMD ["python", "app.py"]
|
||||||
CMD ["./run.sh"]
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
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
|
|
10
lib/reqs.py
10
lib/reqs.py
@ -118,12 +118,6 @@ def get_stream_names(base_url: str, auth: str) -> List[str]:
|
|||||||
List[str]: A list of stream names.
|
List[str]: A list of stream names.
|
||||||
"""
|
"""
|
||||||
url = f"{base_url}/getStreamNames"
|
url = f"{base_url}/getStreamNames"
|
||||||
payload = {}
|
|
||||||
headers = {"Authorization": f"Basic {auth}"}
|
headers = {"Authorization": f"Basic {auth}"}
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
response = requests.get(url, headers=headers)
|
||||||
if response.status_code == 200 and response.text:
|
return json.loads(response.text)
|
||||||
try:
|
|
||||||
return json.loads(response.text)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
return []
|
|
||||||
return []
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
[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"
|
|
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
12
run.sh
12
run.sh
@ -1,12 +0,0 @@
|
|||||||
#!/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
|
|
@ -28,9 +28,3 @@ footer {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Awesomplete and Bootstrap integration fix */
|
|
||||||
div.awesomplete {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>Load Details Via OCR</h2>
|
<h4>Load Details Via OCR</h2>
|
||||||
<form action="/OCRupload" method="POST" enctype="multipart/form-data" onsubmit="showLoadingOCR()">
|
<form action="/OCRupload" method="POST" enctype="multipart/form-data" onsubmit="showLoadingOCR()">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="image">Select Image</label>
|
<label for="image">Select Image</label>
|
||||||
@ -110,7 +110,7 @@
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
new Awesomplete(streamInput, {
|
new Awesomplete(streamInput, {
|
||||||
list: data
|
list: data.map(item => item.streamName)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user