def handle_query_view(): query_term = request.args.get("q") if not query_term: query_term = "" query_page_arg = request.args.get("p") if not query_page_arg: query_page_arg = "1" conn = sqlite3.connect('history.db') c = conn.cursor() # INSERT INTO search_terms (id, term, search_time) VALUES (1, #'baby', strftime('%s', 'now')); delete from search_terms (id, term, search_time) values (1, 'garbage #', strftime('%s', 'now')); #c.executescript(f"INSERT INTO search_terms (id, term, search_time) VALUES (1, '{query_term}', strftime('%s', 'now'));"); c.execute( "INSERT INTO search_terms (term, search_time) VALUES (?, strftime('%s', 'now'));", (query_term, )) c.execute("SELECT * FROM search_terms;") rows = c.fetchall() conn.commit() conn.close() query_page = int(query_page_arg) search_results = query_on_whoosh.query(query_term, current_page=query_page) return render_template("query.html", results=search_results[0], query_term=query_term, page_cnt=math.ceil(search_results[1] / 10), current_page=query_page, history_list=rows)
def foo_url_arg(): if request.method == 'POST': requestDict = request.get_json() queryword = requestDict['query'].strip() print(queryword) docs_result = query_on_whoosh.query(queryword) return jsonify({"echo": queryword, "docs": docs_result})
def handle_query(): query_term = request.args.get("q") query_page = int(request.args.get("p")) return jsonify({ "query_term": query_term, "search_results": query_on_whoosh.query(query_term, current_page=query_page) })
def handle_query(): query_term = request.args.get("q") page_index = int(request.args.get("p")) return jsonify({ "query_term": query_term, "search_results": query_on_whoosh.query(query_term, 10, page_index) })
def handle_query_view(): search_term = request.args.get("q") if not search_term: search_term = "" page_index_arg = request.args.get("p") if not page_index_arg: page_index_arg = "1" page_index = int(page_index_arg) query_results = query_on_whoosh.query(search_term, current_page=page_index) search_results = query_results[0] #return a page of the search results results_cnt = int( query_results[1]) # return a total number of the search results page_cnt = math.ceil(results_cnt / 10) return render_template("query.html", results=search_results, page_cnt=page_cnt, search_term=search_term)
def handle_query_view(): query_term = request.args.get("q") if not query_term: query_term = "" page_index_arg = request.args.get("p") if not page_index_arg: page_index_arg = "1" if query_term != "": #connecting to sqlite database conn = sqlite3.connect('history.db') c = conn.cursor() #c.execute(f"INSERT INTO search_terms (id, term, search_time) VALUES (1, '{query_term}', strftime('%s', 'now'));"); # bryant', strftime('%s', 'now'));delete from search_terms;insert into search_terms(id, term, search_time) values (1, 'garbage c.execute("SELECT enable_history FROM history_settings WHERE id=1;") status = c.fetchone() if status[0] == "on": c.execute( f"INSERT INTO search_terms (term, search_time) VALUES (?, datetime(strftime('%s', 'now'), 'unixepoch', 'localtime', '-5 hours'));", (query_term, )) c.execute("SELECT * FROM search_terms;") rows = c.fetchall() conn.commit() conn.close() page_index = int(page_index_arg) query_results = query_on_whoosh.query(query_term, current_page=page_index) search_results = query_results[0] results_cnt = int(query_results[1]) page_cnt = math.ceil(results_cnt / 10) return render_template("query.html", results=search_results, page_cnt=page_cnt, current_page=page_index, query_term=query_term, history_list=rows) else: return render_template("query.html", page_cnt=0)
def handle_query_view(): if 'history_enabled' not in session: session['history_enabled'] = True query_term = request.args.get("q") topic = request.args.get("topic") p = request.args.get("p") if not query_term and not topic and not p: search_results = 'no search' page_count = 0 else: if not query_term: query_term = '' if not topic: topic = '' if p: page_num = int(p) else: page_num = 1 # only adds to history db if not empty and if search history is enabled if query_term and topic and not p and session['history_enabled']: conn = sqlite3.connect('search_history.db') c = conn.cursor() c.execute( "INSERT INTO search_terms (term, search_time, search_topic) VALUES (?, strftime('%s', 'now'), ?);", (query_term, topic)) conn.commit() conn.close() query_results = query_on_whoosh.query(query_term, topic, 10, page_num) search_results = query_results[0] results_num = int(query_results[1]) page_count = math.ceil(results_num / 10) return render_template("query.html", results=search_results, query_term=query_term, topic=topic, page_count=page_count, topic_list=config.topic_list)
def handle_query_view(): query_term = request.args.get("q") if not query_term: query_term = "" page_index_arg = request.args.get("p") if not page_index_arg: page_index_arg = "1" conn = sqlite3.connect('history.db') c = conn.cursor() c.executescript(f"INSERT INTO search_terms (id, term, search_time) VALUES (?, ?, strftime('%s', 'now'));") c.execute("SELECT * FROM search_terms;") rows = c.fetchall() conn.commit() conn.close() page_index = int(page_index_arg) query_results = query_on_whoosh.query(query_term, current_page=page_index) search_results = query_results[0] results_cnt = int(query_results[1]) page_cnt = math.ceil(results_cnt/10) return render_template("query.html", results = search_results, page_cnt=page_cnt, query_term = query_term, page_index = page_index)
def handle_query_view(): query_term = request.args.get("q") if not query_term: query_term = "" page_index_arg = request.args.get("p") if not page_index_arg: page_index_arg = "1" if query_term != "": conn = sqlite3.connect('history.db') c = conn.cursor() c.execute( "SELECT status FROM settings WHERE id=(SELECT MAX(ID) FROM settings);" ) checkbox = c.fetchone() if checkbox[0] == "enabled": c.execute( "INSERT INTO search_terms (topic, term, search_time) VALUES ('Montessori', ?, datetime(strftime('%s','now'),'unixepoch'));", (query_term, )) conn.commit() conn.close() page_index = int(page_index_arg) query_results = query_on_whoosh.query(query_term, current_page=page_index) search_results = query_results[0] results_cnt = int(query_results[1]) page_cnt = math.ceil(results_cnt / 10) return render_template("query.html", results=search_results, page_cnt=page_cnt, query_term=query_term) else: return render_template("query.html", page_cnt=0)
def handle_query(): search_term = request.args.get("q") n = int(request.args.get('p')) return jsonify(query_on_whoosh.query(search_term, current_page=n))
def handle_query_view(): query_term = request.args.get("q") page_index = int(request.args.get("p")) query_results = query_on_whoosh.query(query_term, current_page=page_index) search_results = query_results[0] return render_template("query.html", results = search_results)
def handle_query_1(): query_term = request.args.get("q") return jsonify({ "query_term": query_term, "search_results": query_on_whoosh.query(query_term) })