Something like this put together.
# tv.py from flask import Flask import pyautogui import time app = Flask(__name__) def change_channel(channel_number): # Test print(channel_number) # Wait for the HDHomerun app to be ready pyautogui.click('HDHR-live.png') time.sleep(25) # Adjust this if needed # Change to the requested channel pyautogui.typewrite(channel_number) time.sleep(2) pyautogui.press('enter') @app.route('/channel/<number>') def channel_name(number): # Call the function to change the channel change_channel(number) return f'Channel changed to {number}!' if __name__ == '__main__': # Run the Flask app, accessible from the network #app.run(host='0.0.0.0', port=5000) app.run()Run.
G:\div_code\foobar λ flask --app tv run * Serving Flask app 'tv' * Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL+C to quit 99 127.0.0.1 - - [16/Sep/2024 22:40:47] "GET /channel/99 HTTP/1.1" 200 -In browser
http://127.0.0.1:5000/channel/99
Output:Channel changed to 99!