-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (25 loc) · 744 Bytes
/
app.py
File metadata and controls
29 lines (25 loc) · 744 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
import os
from flask import Flask, send_from_directory, request
app = Flask(__name__, static_folder='web/explorer/build')
def formatFileInfo(file):
return {
'artist': 'a',
'song': 'b',
'album': 'c'
}
def getFiles(searchString):
files = list(range(100))
return list(map(formatFileInfo, files))
@app.route('/search', methods=['POST'])
def searchFiles():
search = request.get_json()
files = getFiles(search)
print(files)
return {
'results': files
}
@app.route('/', defaults={'path': 'index.html'})
@app.route('/<path:path>')
def reactApp(path):
if path != '' and os.path.exists(app.static_folder + '/' + path):
return send_from_directory(app.static_folder, path)