-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb_ui.py
More file actions
34 lines (22 loc) · 699 Bytes
/
web_ui.py
File metadata and controls
34 lines (22 loc) · 699 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
34
from flask import Flask, render_template, jsonify, request
from threading import Thread
import time
from autoclicker import AutoClicker
app = Flask(__name__)
clicker = AutoClicker()
clicker.set_dry_run(True) # safety: default to dry-run when controlled via web
clicker.start()
@app.route('/')
def index():
return render_template('index.html')
@app.route('/status')
def status():
return jsonify({'running': clicker.running})
@app.route('/toggle', methods=['POST'])
def toggle():
clicker.toggle()
return jsonify({'running': clicker.running})
def run_app(host='127.0.0.1', port=5000):
app.run(host=host, port=port, debug=False)
if __name__ == '__main__':
run_app()