-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathapp.py
66 lines (42 loc) · 1.43 KB
/
app.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
import numpy as np
from flask import Flask, abort, jsonify, request, render_template, send_file
import pickle
import make_song
import make_lyrics
import make_random_lyrics
import json
app = Flask(__name__)
@app.route('/', methods=['GET','POST'])
def song():
if request.method == 'GET':
return render_template('home.html')
midi_list = request.form.getlist('songs')
print('midi_list:', midi_list)
make_song.main(midi_list)
return send_file('your_song.midi')
@app.route('/lyrics', methods=['GET','POST'])
def lyrics():
if request.method == 'GET':
return render_template('home.html')
word_list = request.form.getlist('user_lyrics')
print('word_list: ', word_list)
final_word_list = []
for i in word_list:
j = i.split(',')
for word in j:
word = word.strip()
final_word_list.append(word)
make_lyrics.create_user_lyrics(final_word_list)
return render_template('home.html')
@app.route('/random_lyrics', methods=['GET','POST'])
def random_lyrics():
if request.method == 'GET':
return render_template('home.html')
word_list = request.form.getlist('machine_random_input')
make_random_lyrics.create_user_lyrics(word_list)
return render_template('home.html')
# @app.route('/play_song', methods = ['GET'])
# def play_downloaded_song():
# return send_file('your_song.midi')
if __name__ == '__main__':
app.run(debug=True)