-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
55 lines (41 loc) · 1.12 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
from flask import Flask
from flask import request
from flask import render_template
from sassutils import builder
from search import search
import json
app = Flask(__name__)
compiled = builder.build_directory(
sass_path="static/scss",
css_path="static/css",
strip_extension=False
)
if app.debug or app.env == "development":
print("Compiled scss:", compiled)
@app.route('/', methods=['GET'])
def index():
"""
Index Page
:return: rendered Page
"""
query = request.args.get('q')
print(query)
if query is not None:
return search_component(query)
else:
return render_template('index.html')
def search_component(query):
"""
Index page w/ search results
:return: rendered Page
"""
# text = request.form['search_text']
text = query
# !!!!!!
# WARNING: no text sanitation done here. Expected to be done in search!
# !!!!!!
search_results = search(text)
json_results = json.loads(search_results)
return render_template('index.html', searchResult=json_results, searchComponent=text)
if __name__ == "__main__":
app.run(debug=True)