forked from onlaj/Piano-LED-Visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
63 lines (41 loc) · 1.67 KB
/
Copy pathviews.py
File metadata and controls
63 lines (41 loc) · 1.67 KB
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
from webinterface import webinterface
from flask import render_template, flash, redirect, request, url_for, jsonify, send_file
import os
ALLOWED_EXTENSIONS = {'mid', 'musicxml', 'mxl', 'xml', 'abc'}
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@webinterface.route('/')
def index():
return render_template('index.html')
@webinterface.route('/home')
def home():
return render_template('home.html')
@webinterface.route('/ledsettings')
def ledsettings():
return render_template('ledsettings.html')
@webinterface.route('/ledanimations')
def ledanimations():
return render_template('ledanimations.html')
@webinterface.route('/songs')
def songs():
return render_template('songs.html')
@webinterface.route('/sequences')
def sequences():
return render_template('sequences.html')
@webinterface.route('/ports')
def ports():
return render_template('ports.html')
@webinterface.route('/upload', methods=['POST'])
def upload_file():
if request.method == 'POST':
if 'file' not in request.files:
return jsonify(success=False, error="no file")
file = request.files['file']
filename = file.filename
if os.path.exists("Songs/" + filename):
return jsonify(success=False, error="file already exists", song_name=filename)
if not allowed_file(file.filename):
return jsonify(success=False, error="not a midi file", song_name=filename)
filename = filename.replace("'", "")
file.save(os.path.join(webinterface.config['UPLOAD_FOLDER'], filename))
return jsonify(success=True, reload_songs=True, song_name=filename)