Compare commits
	
		
			3 Commits
		
	
	
		
			dbb1eb7b17
			...
			603d178d03
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 603d178d03 | |||
| 30918daeb4 | |||
| 09293b5cf2 | 
							
								
								
									
										24
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							| @ -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", |     "version": "0.2.0", | ||||||
|     "configurations": [ |     "configurations": [ | ||||||
|         { |         { | ||||||
|             "name": "Python Debugger: Current File", |             "name": "Python: Flask", | ||||||
|             "type": "debugpy", |             "type": "debugpy", | ||||||
|             "request": "launch", |             "request": "launch", | ||||||
|             "program": "${file}", |             "module": "flask", | ||||||
|             "console": "integratedTerminal", |             "env": { | ||||||
|             "justMyCode": false, |                 "FLASK_APP": "app.py", | ||||||
|             "args": ["--host=0.0.0.0"] |                 "FLASK_ENV": "development" | ||||||
|  |             }, | ||||||
|  |             "args": [ | ||||||
|  |                 "run", | ||||||
|  |                 "--no-debugger", | ||||||
|  |                 "--port", | ||||||
|  |                 "5005", | ||||||
|  |                 "--host", | ||||||
|  |                 "0.0.0.0" | ||||||
|  |             ], | ||||||
|  |             "jinja": true, | ||||||
|  |             "justMyCode": true | ||||||
|         } |         } | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
							
								
								
									
										13
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								app.py
									
									
									
									
									
								
							| @ -9,23 +9,26 @@ 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  | from config import DevelopmentConfig, ProductionConfig | ||||||
| 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( | 
 | ||||||
|     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"}) | 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'] = 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_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,9 +17,12 @@ 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 8089 | EXPOSE 5000 | ||||||
| 
 | 
 | ||||||
| CMD ["python", "app.py"] | ENV FLASK_ENV production | ||||||
|  | CMD ["./run.sh"] | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								gunicorn.conf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								gunicorn.conf.py
									
									
									
									
									
										Normal 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 | ||||||
							
								
								
									
										10
									
								
								lib/reqs.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								lib/reqs.py
									
									
									
									
									
								
							| @ -118,6 +118,12 @@ 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.get(url, headers=headers) |     response = requests.request("GET", url, headers=headers, data=payload) | ||||||
|     return json.loads(response.text) |     if response.status_code == 200 and response.text: | ||||||
|  |         try: | ||||||
|  |             return json.loads(response.text) | ||||||
|  |         except json.JSONDecodeError: | ||||||
|  |             return [] | ||||||
|  |     return [] | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								pyproject.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								pyproject.toml
									
									
									
									
									
										Normal 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" | ||||||
							
								
								
									
										
											BIN
										
									
								
								requirements.txt
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								requirements.txt
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										12
									
								
								run.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								run.sh
									
									
									
									
									
										Normal 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 | ||||||
| @ -28,3 +28,9 @@ 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> | ||||||
|         <h4>Load Details Via OCR</h2> |         <h2>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.map(item => item.streamName) |                         list: data | ||||||
|                     }); |                     }); | ||||||
|                 }); |                 }); | ||||||
|         }); |         }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user