forked from NicolasSkopek/LIMINAL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (26 loc) · 901 Bytes
/
main.py
File metadata and controls
35 lines (26 loc) · 901 Bytes
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
import os
from flask import Flask, render_template, url_for, redirect
import json
import random
import string
app = Flask(__name__)
def randomString(range1, range2):
length = random.randint(range1, range2)
return str(''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase +
string.digits, k=length)))
@app.route("/", methods=["GET"])
def index():
return redirect(url_for("desktop"))
@app.route("/desktop", methods=["GET"])
def desktop():
with open("data.json") as f:
data = f.read()
spaces = json.loads(data)
random.shuffle(spaces)
path = "static/styles/audios/songs"
files = os.listdir(path)
songs = [file for file in files]
random.shuffle(songs)
return render_template("desktop.html", spaces=spaces, songs=songs, randomString=randomString)
if __name__ == '__main__':
app.run(debug=True)