From cb9c7e58fa12e182af08918dcf952a9ec8c546ad Mon Sep 17 00:00:00 2001 From: Dhruv Venkataraman Date: Sun, 2 Oct 2022 23:32:41 -0400 Subject: Added backend --- backend/app.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 backend/app.py diff --git a/backend/app.py b/backend/app.py new file mode 100644 index 0000000..6d38cd4 --- /dev/null +++ b/backend/app.py @@ -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/') +def freq(freq): + print(freq) + thread2 = Thread(target=playFunction, args=freq) + return("200") + +@app.route('/stopfreq/') +def freq2(freq2): + global threadFlag + threadFlag = True + return("200") + +if __name__ == "__main__": + app.run(debug=True, host='0.0.0.0') + + + + \ No newline at end of file -- cgit v1.2.3-70-g09d2