import os
from flask import Flask
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
# -------------- VARIABLES --------------
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)
scroll_pixels = 100
scroll_interval = 3 # seconds
bottom_wait_time = 3 # seconds
top_wait_time = 3 # seconds
reload_interval = 35 # seconds
# -------------- END VARIABLES --------------
app = Flask(__name__)
class FileChangeHandler(FileSystemEventHandler):
def __init__(self, app):
self.app = app
def on_modified(self, event):
if event.src_path == html_file_path:
with self.app.app_context():
self.app.config['TEMPLATES_AUTO_RELOAD'] = True
@app.route('/')
def serve_html():
with open(html_file_path, 'r', encoding= ('latin-1' if is_oe11 else 'utf-8') ) as file:
content = file.read()
content += f'''
'''
return content
if __name__ == '__main__':
event_handler = FileChangeHandler(app)
observer = Observer()
observer.schedule(event_handler, path=os.path.dirname(html_file_path), recursive=False)
observer.start()
try:
app.run(host=host, port=port)
except KeyboardInterrupt:
observer.stop()
observer.join()