blob: b0c6ade390953c1cb225b84130d4383074950b3f (
plain)
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
35
36
|
from flask import Flask
from threading import Thread
import os
import subprocess
app = Flask(__name__)
curf = 0
p = 0
tc = 0
@app.before_first_request
def activate_job():
global tc
tc = 0
@app.route('/startfreq/<f>')
def startfreq(f):
global curf
global p
print(f)
curf = f
p = subprocess.Popen(["beep", "-f", f, "-l", "100000"]).pid
return("200")
@app.route('/stopfreq/<f>')
def stopfreq(f):
print(f, curf)
if f == curf:
os.kill(p, 15)
return("200")
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')
|