Compare commits

..

2 Commits

Author SHA1 Message Date
d8a8a6d16e added en/hu readme and license 2025-04-02 15:22:43 +02:00
40f0d05290 updated main.py for oe11 encoding 2025-04-02 12:42:55 +02:00
4 changed files with 170 additions and 57 deletions

7
LICENSE Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2025 Norbert Jovari
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

84
README.en.md Normal file
View File

@@ -0,0 +1,84 @@
# SportSoftware OE HTML viewer
<hr>
[![hu](https://img.shields.io/badge/lang-hu-blue.svg)](https://gitea.carburator.dev/carburator/oe-html-viewer/src/branch/main/README.md)
Simple Python script to serve the exported HTML results file from the SportSoftware OE application on the local network.
Use it to display the results on a TV or to serve results for the competitors.
## Features
<ul style="list-style-type: none"> ✅ Customizable auto-scroll (see Variables section) </ul>
<ul style="list-style-type: none"> ✅ Smooth scrolling </ul>
<ul style="list-style-type: none"> ✅ Auto-reload at bottom </ul>
<ul style="list-style-type: none"> ✅ Auto-reload at X seconds when no need for scrolling </ul>
<ul style="list-style-type: none"> ✅ Supports OE11 and OE12 exported HTML </ul>
<ul style="list-style-type: none"> ✅ File serving on localhost and LAN </ul>
### Variables
The following variables can be found at the top of the `main.py` script:
- `html_file_path`: Path to the HTML file to be served. Example: `C:\Users\<username>\Documents\example-event\results.html`
- `host`: Host address for the Flask application. Leave at `0.0.0.0` for availability at all network addresses (localhost / LAN)
- `port`: Port number for the Flask application
- `is_oe11`: Boolean flag for encoding (`True` for OE11, `False` for OE12)
- `scroll_pixels`: Number of pixels to scroll each interval
- `scroll_interval`: Time interval (in seconds) between each scroll
- `bottom_wait_time`: Time to wait (in seconds) at the bottom of the page before reloading
- `top_wait_time`: Time to wait (in seconds) at the top of the page before starting to scroll
- `reload_interval`: Time interval (in seconds) to reload the page if no scrolling is needed. Set this value minimum 1 seconds larger than the export interval in OE
## Getting Started
### Prerequisites
- Python 3.x
- pip
- virtualenv
### Installation
Run these commands in CMD or PowerShell.
1. Clone the repository:
```sh
git clone https://gitea.carburator.dev/carburator/oe-html-viewer.git
cd oe-html-viewer
```
2. Create a virtual environment:
```sh
python -m venv .venv
```
3. Activate the virtual environment:
```sh
.venv\Scripts\activate
```
4. Install the required packages:
```sh
pip install -r requirements.txt
```
### Running the Application
0. If you downloaded earlier and want to use the program again, first activate the venv. Check: Installation - 3.
1. Start the Flask application:
```sh
python main.py
```
2. Open your web browser and navigate to `http://localhost:80`. From other devices on LAN: `http://<host machine IP address>`
### License
This project is licensed under the MIT License - see the `LICENSE` file for details.
<hr>
<p style="text-align: center;"> Made with ❤️ on 603 NYÍRSÉG IC </p>

109
README.md
View File

@@ -1,67 +1,84 @@
# SportSoftware OE HTML viewer
# SportSoftware OE HTML megjelenítő
Simple Python script to serve the exported HTML results file from the SportSoftware OE application on the local network.
<hr>
## Getting Started
[![en](https://img.shields.io/badge/lang-en-blue.svg)](https://gitea.carburator.dev/carburator/oe-html-viewer/src/branch/main/README.en.md)
### Prerequisites
Egyszerű python program, amivel a tájfutó eseményeken használt OE11 és OE12 programból exportált HTML fájlokat lehet megjeleníteni kijelzőn, vagy a helyi hálózaton.
## Funkciók
<ul style="list-style-type: none"> ✅ Személyre szabható automatikus görgetés </ul>
<ul style="list-style-type: none"> ✅ Finom görgetés </ul>
<ul style="list-style-type: none"> ✅ Automatikus újratöltés a lap alján </ul>
<ul style="list-style-type: none"> ✅ Automatikus újratöltés, ha nincs szükség görgetésre </ul>
<ul style="list-style-type: none"> ✅ Támogatja az OE11 és OE12-ből exportált HTML fájlokat is </ul>
<ul style="list-style-type: none"> ✅ Megjeleníti a fájlt localhost-on és a helyi hálózaton is </ul>
### Változók
A `main.py` fájl elején található, szerkeszthető változók:
- `html_file_path`: Elérési út a HTML fájlhoz. Példa: `C:\Users\<felhasználó>\Documents\példa-verseny\eredmenyek.html`
- `host`: A webszerver IP címe. Hagyd az alapértelmezett `0.0.0.0` értéken, hogy elérhető legyen a fájl lokálisan és a lokális hálózaton is
- `port`: A webszerver portja. Alapértelmezetten `80`, ez elhagyható az URL-ből
- `is_oe11`: Változó az OE11 vagy OE12 kiválasztására. Legyen `True` ha OE11-et használsz és `False`, ha OE12-t
- `scroll_pixels`: Ennyi pixelt görget lefelé
- `scroll_interval`: Időtartam másodpercben, ennyi időnként görget
- `bottom_wait_time`: Időtartam másodpercben, ennyit vár ha a lap aljára ért újratöltés előtt
- `top_wait_time`: Időtartam másodpercben, ennyit vár a lap tetején, mielőtt elkezdődne a görgetés
- `reload_interval`: Időtartam másodpercben, ennyit vár újratöltés előtt, ha nincs szükség görgetésre, mert a tartalom kifér a képernyőre. Legyen ez az érték minimum 1 másodperccel több, mint az automatikus exportálás ideje az OE-ben.
## Használat
### Előfeltételek
- Python 3.x
- pip
- virtualenv
### Installation
### Telepítés
A következő parancsokat CMD-ben vagy PowerShell-ben kell kiadni.
1. Clone the repository:
```sh
git clone https://gitea.carburator.dev/carburator/oe-html-viewer.git
cd oe-html-viewer
```
1. Töltsd le a repository-t:
2. Create a virtual environment:
```sh
python -m venv .venv
```
```sh
git clone https://gitea.carburator.dev/carburator/oe-html-viewer.git
cd oe-html-viewer
```
3. Activate the virtual environment:
2. Hozz létre egy virtuális környezetet:
- On Windows:
```sh
.venv\Scripts\activate
```
- On macOS/Linux:
```sh
source .venv/bin/activate
```
```sh
python -m venv .venv
```
4. Install the required packages:
```sh
pip install -r requirements.txt
```
3. Aktiváld a virtuális környezetet:
### Running the Application
```sh
.venv\Scripts\activate
```
1. Start the Flask application:
```sh
python main.py
```
4. Telepítsd a szükséges csomagokat:
```sh
pip install -r requirements.txt
```
2. Open your web browser and navigate to `http://localhost:80`.
### Futtatás
### Variables
0. Ha már telepítetted és újra használni akarod, akkor előbb aktiváld a virtuális környezetet. Lásd: Telepítés - 3.
The following variables can be found at the top of the `main.py` script:
1. Indítsd el a programot:
- `html_file_path`: Path to the HTML file to be served.
- `host`: Host address for the Flask application. Leave at `0.0.0.0` for availability at all network addresses (localhost / LAN)
- `port`: Port number for the Flask application.
- `is_oe11`: Boolean flag for encoding (True for OE11, False for OE12).
- `scroll_pixels`: Number of pixels to scroll each interval.
- `scroll_interval`: Time interval (in seconds) between each scroll.
- `bottom_wait_time`: Time to wait (in seconds) at the bottom of the page before reloading.
- `top_wait_time`: Time to wait (in seconds) at the top of the page before starting to scroll.
- `reload_interval`: Time interval (in seconds) to reload the page if no scrolling is needed. Set this value minimum 1 seconds larger than the export interval in OE.
```sh
python main.py
```
### License
2. Nyisd meg a böngészőt és írd be a címsorba: `http://localhost`. Más eszközről a helyi hálózaton: `http://<host gép ip címe>`
This project is licensed under the MIT License - see the `LICENSE` file for details.
### Licensz
Ez a projekt az MIT Licensz alatt van licenszelve - részletekért lásd a LICENSE fájlt.
<hr>
<p style="text-align: center;"> Készült sok ❤️-el a 603 NYÍRSÉG IC-n </p>

25
main.py
View File

@@ -4,10 +4,10 @@ from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
# -------------- VARIABLES --------------
html_file_path = r'PATH'
host = '0.0.0.0'
html_file_path = r"PATH"
host = "0.0.0.0"
port = 80
is_oe11 = True # if using OE11 set it to True, for OE12 set it to False (encoding)
is_oe11 = True # if using OE11 set it to True, for OE12 set it to False (encoding)
scroll_pixels = 100
scroll_interval = 3 # seconds
bottom_wait_time = 3 # seconds
@@ -17,6 +17,7 @@ reload_interval = 35 # seconds
app = Flask(__name__)
class FileChangeHandler(FileSystemEventHandler):
def __init__(self, app):
self.app = app
@@ -24,13 +25,14 @@ class FileChangeHandler(FileSystemEventHandler):
def on_modified(self, event):
if event.src_path == html_file_path:
with self.app.app_context():
self.app.config['TEMPLATES_AUTO_RELOAD'] = True
self.app.config["TEMPLATES_AUTO_RELOAD"] = True
@app.route('/')
@app.route("/")
def serve_html():
with open(html_file_path, 'r', encoding= ('latin-1' if is_oe11 else 'utf-8') ) as file:
with open(html_file_path, "r", encoding=("cp1252" if is_oe11 else "utf-8")) as file:
content = file.read()
content += f'''
content += f"""
<style>
html {{
scroll-behavior: smooth;
@@ -80,13 +82,16 @@ def serve_html():
}}
}};
</script>
'''
"""
return content
if __name__ == '__main__':
if __name__ == "__main__":
event_handler = FileChangeHandler(app)
observer = Observer()
observer.schedule(event_handler, path=os.path.dirname(html_file_path), recursive=False)
observer.schedule(
event_handler, path=os.path.dirname(html_file_path), recursive=False
)
observer.start()
try:
app.run(host=host, port=port)