def search(): query = request.forms.get('q') sectionData = None if query: sectionTemplate = "./templates/search_result.tpl" sectionData = utils.get_search_results(query) else: sectionTemplate = "./templates/search.tpl" return template("./pages/index.html", version=utils.getVersion(), sectionTemplate=sectionTemplate, sectionData={}, query=query, results=sectionData)
def get_search(search: SearchQuery = Depends()): query = {} search.register(query) item = mongo_client.find(query) if item: mongo_client.update(query) return item['results'] else: results = get_search_results(search.text) if isinstance(results, dict): return JSONResponse(results, HTTPStatus.INTERNAL_SERVER_ERROR) query["text"] = search.text query['results'] = results mongo_client.insert(query) return JSONResponse(results, HTTPStatus.OK)
async def cherche(ctx, *, args): results = utils.get_search_results(args) if results: result = results[0] embed = discord.Embed( type='rich', title=result['title'], description=result['description'], url=ROOT_URL + result['url'], ) if result['thumbnail']: embed.set_thumbnail(url=ROOT_URL + result['thumbnail']) await ctx.send(content='Voici ce que j\'ai trouvé !', embed=embed) else: custom = discord.utils.get(ctx.bot.emojis, name='clemtriste') if custom: emoji = '<:{}:{}>'.format(custom.name, custom.id) else: emoji = '🙁' await ctx.send('{} Je n\'ai rien trouvé à ce sujet.'.format(emoji))
def _get_search_results(self): return get_search_results(self)['results']
def search_results(self): results = get_search_results(self) results['fields'] = self.get_table_fields() results['id'] = "flexitopicresults" results['display_legend'] = (results['num_results'] > 0) return results