def article(): url = request.args.get('url') article = cached_call(article_reader.get_article, url) return render_template('article.html', article=article, with_back=get_with_back(request), back_url=request.args.get('back_url'))
def topic(): topic_id = request.args.get('id') topic = cached_call(news_browser.fetch_topic, topic_id) return render_template('topic.html', topic=topic, with_back=get_with_back(request), back_url=request.args.get('back_url'))
def search(query): """Respond with a list of search results. """ results = cached_call(news_searcher.search, query=query) return render_template('search_results.html', results=results, query=query, with_back=get_with_back(request), back_url='/')
def index(): """Homepage, list news topics or respond with search results if X-Mxit-User-Input is present. """ query = request.form.get('X-Mxit-User-Input') if query: # The user has submitted a search query. return search(query) else: # The user is requesting the home page. topics = news_browser.topics return render_template('index.html', topics=topics, debug=True, with_back=get_with_back(request), back_url=request.args.get('back_url'))