-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_search.py
More file actions
23 lines (17 loc) · 843 Bytes
/
server_search.py
File metadata and controls
23 lines (17 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Blueprint, render_template, request
import data_manager
route_search = Blueprint('search', __name__, template_folder='templates')
@route_search.route('/questions', methods=['POST'])
def route_search_question():
pattern = request.form["search_input"]
questions = data_manager.search_questions(pattern)
return render_template('index.html', questions=questions)
@route_search.route('/answer/<question_id>', methods=['POST'])
def route_search_answer(question_id):
pattern = request.form["search_input"]
question = data_manager.get_question_by_id(question_id)
answers = data_manager.search_answer(pattern)
return render_template('display_question.html',
question=question,
answers=answers,
question_id=question_id)