diff --git a/app/main.py b/app/main.py index 496724c..c342a16 100644 --- a/app/main.py +++ b/app/main.py @@ -81,6 +81,14 @@ def within_range(x, y, r): return x > y and abs(x - y) <= r +def get_article_title(s): + return s.split('\n')[0] + + +def get_article_body(s): + return '\n'.join(s.split('\n')[1:-1]) # remove the first line + + def get_today_article(user_word_list, articleID): rq = RecordQuery(path_prefix + 'static/wordfreqapp.db') @@ -113,7 +121,10 @@ def get_today_article(user_word_list, articleID): s = '
Article added on: %s
' % (d['date']) s += '%s
' % (d['text']) + article_title = get_article_title(d['text']) + article_body = get_article_body(d['text']) + s += '%s
' % (article_title) + s += '%s
' % (article_body) s += '%s
' % (d['source']) s += '%s
' % (get_question_part(d['question'])) s = s.replace('\n', '