-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 786 Bytes
/
Copy pathmain.py
File metadata and controls
33 lines (27 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, request, jsonify
import pyautogui
app = Flask(__name__)
@app.route('/')
def index():
return open('remote.html', encoding='utf-8').read()
@app.route('/action', methods=['POST'])
def action():
data = request.json
cmd = data.get('cmd')
if cmd == 'up':
pyautogui.press('up')
elif cmd == 'down':
pyautogui.press('down')
elif cmd == 'left':
pyautogui.press('left')
elif cmd == 'right':
pyautogui.press('right')
elif cmd == 'enter':
pyautogui.press('enter')
elif cmd == 'back':
pyautogui.press('esc')
elif cmd == 'play_pause':
pyautogui.press('space')
return jsonify({"status": "ok", "cmd": cmd})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)