diff --git a/src/core/__init__.py b/src/core/__init__.py index 000ec71..3923875 100644 --- a/src/core/__init__.py +++ b/src/core/__init__.py @@ -4,6 +4,7 @@ from datetime import timedelta # Lib imports +import pyautogui import eventlet from engineio.payload import Payload @@ -23,11 +24,12 @@ from flask_socketio import SocketIO # Configs and 'init' +APP_NAME = 'RemoteMouse' ROOT_FILE_PTH = os.path.dirname(os.path.realpath(__file__)) app = Flask(__name__) app.config.update({ - "TITLE": 'RemoteMouse', + "TITLE": APP_NAME, 'DEBUG': False, 'SECRET_KEY': secrets.token_hex(32), 'PERMANENT_SESSION_LIFETIME': timedelta(days = 7).total_seconds() @@ -45,4 +47,10 @@ socketio = SocketIO(app, async_mode = 'eventlet', logger = True) +app.jinja_env.globals['TITLE'] = APP_NAME +pyautogui.FAILSAFE = False # If we hit corner, that's ok +# Let piautogui make updates as quick as it can... +pyautogui.MINIMUM_DURATION = 0 +pyautogui.PAUSE = 0 + from core import routes diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index d92aa9d..784ea98 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -7,24 +7,17 @@ from flask import request, render_template # App imports -from core import app, socketio # Get from __init__ +from core import app, pyautogui, socketio # Get from __init__ from core.MessageHandler import MessageHandler # Get simple message processor msgHandler = MessageHandler() -TITLE = app.config['TITLE'] - -pyautogui.FAILSAFE = False # If we hit corner, that's ok -# Let piautogui make updates as quick as it can... -pyautogui.MINIMUM_DURATION = 0 -pyautogui.PAUSE = 0 @app.route('/') def home(): if request.method == 'GET': - return render_template('index.html', - title=TITLE) + return render_template('index.html') return render_template('error.html', title='Error!', @@ -42,7 +35,6 @@ def soundManager(): print(process.stdout.read()) _apps = [] return render_template('sound-manager.html', - title=TITLE, apps=_apps) return render_template('error.html', diff --git a/src/core/routes/Sockets.py b/src/core/routes/Sockets.py index 14a32a5..e22f4f7 100644 --- a/src/core/routes/Sockets.py +++ b/src/core/routes/Sockets.py @@ -6,7 +6,7 @@ from flask import request, render_template # App imports -from core import app, socketio # Get from __init__ +from core import app, pyautogui, socketio # Get from __init__ from core.MessageHandler import MessageHandler # Get simple message processor @@ -14,11 +14,6 @@ from core.MessageHandler import MessageHandler # Get simple message processor msgHandler = MessageHandler() -pyautogui.FAILSAFE = False # If we hit corner, that's ok -# Let piautogui make updates as quick as it can... -pyautogui.MINIMUM_DURATION = 0 -pyautogui.PAUSE = 0 - @app.route('/mouse-down') @socketio.on('mouse_down') @@ -79,4 +74,4 @@ def updateCoords(message): # print(str(x) + "," + str(y)) pyautogui.moveRel(x, y); except Exception as e: - print( repr(e) ) + pass diff --git a/src/core/templates/layout.html b/src/core/templates/layout.html index 4d3d9bf..d19c2b6 100644 --- a/src/core/templates/layout.html +++ b/src/core/templates/layout.html @@ -6,7 +6,7 @@ {% if title %} {{title}} {% else %} - App + {{TITLE}} {% endif %} {% block header_css %}