-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.py
68 lines (56 loc) · 1.93 KB
/
deploy.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
from flask import Flask, render_template, request, jsonify
from recommender import ret_name, ret_id, ret_id1
from search import find
app = Flask(__name__)
@app.route('/',methods=['POST','GET'])
def main():
list1=ret_name('101')
list2=ret_id('101')
return render_template("index.html",s1=list1,s2=list2)
@app.route('/a',methods=['GET'])
def a():
if request.method == 'GET':
song = request.args.get('song_data')
list1=ret_name(song)
list2=ret_id(song)
return jsonify({'s1':list1,'s2':list2})
@app.route('/b',methods=['GET'])
def b():
if request.method == 'GET':
name=request.args.get('song_name')
sugg_list=find(name)
return jsonify({'sugg':sugg_list})
@app.route('/autosearch',methods=['GET'])
def c():
if request.method == 'GET':
name=request.args.get('song_data')
sugg_list=find(name)#['hello','hello','hello','hello','hello','hello','hello','hello','hello','hello']
print(sugg_list)
return jsonify({'list':sugg_list,'size':len(sugg_list)})
@app.route('/search',methods=['GET'])
def d():
if request.method == 'GET':
name=request.args.get('song_data')
sid=ret_id1(name)
if id != -1:
list1=ret_name(sid)
list2=ret_id(sid)
else:
list1=[]
list2=[]
return jsonify({'id':sid,'s1':list1,'s2':list2})
if __name__ == '__main__':
app.run(debug=True)
#if request.method == 'GET':
#song1 = request.form['input']
#x=request.get_json()
#song1=request.args.get('song_data')
#if song1==None:
# song1='101'
#song2= func(song1)
#return render_template("index.html",s1=song1,s2=song2)
#return render_template("index.html",{'s1':json.dumps(song1),'s2':json.dumps(song2)})
#else:
# song1=request.json['song_data']
# song2=func('102')
# return song1