fix template error in bundled onefile exec

This commit is contained in:
Mathieu Broillet 2024-07-17 23:00:09 +02:00
parent aa0cf11dd8
commit 645ae397b4
Signed by: mathieu
GPG Key ID: A08E484FE95074C1
2 changed files with 3 additions and 4 deletions

View File

@ -10,6 +10,7 @@ from PIL import Image
from flask import Flask, request, jsonify, render_template
counter = 0
bundle_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
"""
Hi there!
@ -55,8 +56,6 @@ IMAGE_TYPES_MAPPING = {
def load_engine():
bundle_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
JSON_CONFIG["assets_folder"] = os.path.join(bundle_dir, "assets")
JSON_CONFIG.update({
"charset": "latin",
@ -116,7 +115,7 @@ def process_image(image: Image) -> str:
def create_rest_server_flask():
app = Flask(__name__)
app = Flask(__name__, template_folder=os.path.join(bundle_dir, 'templates'))
@app.route('/v1/image/alpr', methods=['POST'])
def alpr():

View File

@ -1 +1 @@
pyinstaller --noconfirm --onefile --console --add-data libs:. --add-data assets:assets --name easy-local-alpr-1.0.0-linux_x86_64 "alpr_api.py"
pyinstaller --noconfirm --onefile --console --add-data libs:. --add-data assets:assets --add-data static:static --add-data templates:templates --name easy-local-alpr-1.0.0-linux_x86_64 "alpr_api.py"