-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
70 lines (47 loc) · 1.6 KB
/
server.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from flask import Flask, render_template, url_for, send_from_directory
from funcs import GetIp, GenerateQr, sorted_alphanumeric, stopMusic, startMusic, changeVolume
import os
print("Hello world")
app = Flask(__name__)
#home webpage
@app.route('/')
def home():
return render_template('home.html')
#page to start the music
@app.route("/start/<number>")
def startPlaying(number):
print(f"Should start this music {number}")
if int(number) > len(fileList):
print(f" Requested music {number} does not exist")
return("failed")
path = fileList[int(number) - 1]
if startMusic(path):
return ("accepted")
else:
return ("failed")
#page to stop the music
@app.route("/stop")
def stopPlaying():
#will i need to check if the music is playing?
print("This should stop the music")
stopMusic()
return ("stopped")
#page for volume changes
@app.route("/volume/<increment>")
def changeVol(increment):
print(f"Should change the volume by: {increment}")
changeVolume(int(increment))
return ("volumechange")
#import the js files
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
if __name__ == '__main__':
fileList = [os.path.join("cantados", x) for x in os.listdir("cantados") if x.split(".")[-1] == "mp4" or x.split(".")[-1] == "mkv"]
fileList = sorted_alphanumeric(fileList)
myIp = GetIp()
port = 4443
print(f"Starting server http://{myIp}:{port}")
GenerateQr(f"http://{myIp}:{port}")
print("Starting Server")
app.run(host=myIp, port=4443, debug=False)