-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
69 lines (46 loc) · 1.91 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
67
68
69
from flask import Flask, render_template, request
import search
from Settings import Settings
app = Flask(__name__)
global_scope = {
'search_terms': None,
'roles': [],
'bowling_styles': []
}
@app.route('/')
def home():
return render_template('search.html')
@app.route('/search/results', methods=['GET', 'POST'])
def search_request():
search_term = request.form["input"]
res, roles, bowling_styles = search.search(search_term)
global_scope['search_terms'] = search_term
global_scope['roles'] = roles
global_scope['bowling_styles'] = bowling_styles
res['search_term'] = global_scope.get('search_terms')
print(global_scope.get('search_terms'))
return render_template('results.html', res=res, roles=roles, bowling_styles=bowling_styles)
@app.route('/search/results/filter', methods=['GET', 'POST'])
def faceted_search_request():
role_filter = []
bowling_style_filter = []
for role in global_scope.get('roles'):
if request.form.get(role["id"]):
role_filter.append(role)
for bowling_style in global_scope.get('bowling_styles'):
if request.form.get(bowling_style["id"]):
bowling_style_filter.append(bowling_style)
search_term = global_scope.get('search_terms')
res, roles, bowling_styles = search.search(search_term, role_filter, bowling_style_filter)
print(role_filter, bowling_style_filter)
res['search_term'] = global_scope.get('search_terms')
print(global_scope.get('search_terms'))
return render_template('results.html', res=res, roles=roles, bowling_styles=bowling_styles)
@app.route('/profile/<string:id>', methods=['GET'])
def get_user_profile(id):
player = search.get_player_by_id(id)
return render_template('profile.html', res=player)
if __name__ == '__main__':
app.debug = True
app.secret_key = 'mysecret'
app.run(host=Settings.flask_host.value, port=Settings.flask_port.value)