diff options
author | Dhruv Venkataraman | 2022-10-02 23:32:41 -0400 |
---|---|---|
committer | Dhruv Venkataraman | 2022-10-02 23:32:41 -0400 |
commit | cb9c7e58fa12e182af08918dcf952a9ec8c546ad (patch) | |
tree | bfd2363fe9d90667d2dcfdd3af8e420aa33995ad | |
parent | 0162fb04402567646501f17e6ef6542cc0d85da5 (diff) |
Added backend
-rw-r--r-- | backend/app.py | 38 |
1 files changed, 38 insertions, 0 deletions
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/<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') + + + +
\ No newline at end of file |