def index(): """ Input: No user input, but uses articles.csv and tweets.csv Output: Creates the page with the tweets and ny times articles that result from a given search """ if request.method == "POST": twitter.search(request.form['searchterm']) nyt.search(request.form['searchterm']) f = open('tweets.csv', 'r') tweets = f.read() f.close() tweets = tweets.decode('utf-8') g = open('articles.csv', 'r') articles = g.read() g.close() articles = articles.decode('utf-8') return render_template("index.html", twitter=tweets, nyt=articles) return render_template("index.html", twitter='No Search Has Been Done', nyt='No Search Has Been Done')
def search(): if request.method=="POST": twitter.search(request.form['searchterm']) nyt.search(request.form['searchterm']) f = open('tweets.csv','r') tweets = f.read() f.close() tweets = tweets.decode('utf-8') g = open('articles.csv','r') articles = g.read() g.close() articles = articles.decode('utf-8') return render_template("search.html",twitter=tweets,nyt=articles) return render_template("search.html",twitter='No Search Has Been Done',nyt='No Search Has Been Done')
def handle_keypress(key): if key == 'enter': if top.get_body() is sscreen: query = search_screen_text(sscreen) if query: results = nyt.search(query) show_article_list(results) # vim-like bindings if key == 'j': top.get_body().keypress((100, 50), 'down') if key == 'k': top.get_body().keypress((100, 50), 'up') if key == 'l' or key == 'right': top.get_body().keypress((100, 50), 'enter') if key == 'left' or key == 'h': if len(view_chain) > 1: view_chain.pop() top.set_body(view_chain[-1]) if key == 'q': raise urwid.ExitMainLoop()
def index(): """ Input: No user input, but uses articles.csv and tweets.csv Output: Creates the page with the tweets and ny times articles that result from a given search """ if request.method=="POST": twitter.search(request.form['searchterm']) nyt.search(request.form['searchterm']) f = open('tweets.csv','r') tweets = f.read() f.close() tweets = tweets.decode('utf-8') g = open('articles.csv','r') articles = g.read() g.close() articles = articles.decode('utf-8') return render_template("index.html",twitter=tweets,nyt=articles) return render_template("index.html",twitter='No Search Has Been Done',nyt='No Search Has Been Done')