Added backend

This commit is contained in:
Dhruv Venkataraman 2022-10-02 23:32:41 -04:00
parent 0162fb0440
commit cb9c7e58fa

38
backend/app.py Normal file
View file

@ -0,0 +1,38 @@
from flask import Flask
from threading import Thread
import os
app = Flask(__name__)
threadFlag = True
def playFunction(freq):
global threadFlag
while not threadFlag:
os.system("beep -f %f" % (freq))
#print("beep -f %f" % (freq))
tc = 0
@app.before_first_request
def activate_job():
global tc
tc = 0
@app.route('/startfreq/<freq>')
def freq(freq):
print(freq)
thread2 = Thread(target=playFunction, args=freq)
return("200")
@app.route('/stopfreq/<freq2>')
def freq2(freq2):
global threadFlag
threadFlag = True
return("200")
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')