Example #1
0
def search():

    page = int(request.args.get('page', 1))
    count = len(word_list)
    data = sorted(word_list)
    pager = Pager(page, count)
    pages = pager.get_pages()
    skip = (page - 1) * current_app.config['PAGE_SIZE']
    limit = current_app.config['PAGE_SIZE']
    data_to_show = data[skip:skip + limit]

    if request.method == 'POST':
        result = request.form
        response = find_line(result['Word'].lower())
        if response is not None:
            test_data = tests_data[str(response['id'])]
            return render_template('result.html',
                                   response=response,
                                   word=result['Word'],
                                   test_data=test_data)
        else:
            return render_template('slovar.html',
                                   pages=pages,
                                   data_to_show=data_to_show,
                                   error=True)
Example #2
0
def index():
    #page = int(request.args.get('page', 1))
    query = request.args.get("query", None)
    q = query
    
    if query:
        #app.logger.info("Query {} received".format(query))
        page = int(request.args.get('page', 1))
        #query = request.args.get("query", None)
        results = retrieve(query)
        
        if (len(results)>0):
            count = len(results)
            data = results
            pager = Pager(page, count)
            pages = pager.get_pages()
            skip = (page - 1) * current_app.config['PAGE_SIZE']
            limit = current_app.config['PAGE_SIZE']
            data_to_show = data[skip: skip + limit]
            #print(data_to_show)
            return render_template('results.html', pages=pages, query=query, data_to_show=data_to_show)
        else:
            return render_template('no_results.html', query=query)

    else:
        return render_template('index.html')
Example #3
0
def catalogS():
    if request.method == 'GET':
        cate = request.values["cate"]
        time = request.values['time']
        with get_db_con() as con:
            cur = con.cursor()

            mov_info_all = '''select * from Mov_info  where mov_info like '%''' + cate + '''%' and mov_info like '%''' + time + '''%' order by mov_date desc'''

            mov_info_all = cur.execute(mov_info_all)
            mov_info_all = list(mov_info_all.fetchall())

            url = 'http://www.kobis.or.kr/'

            total_all = '''select count(*) from mov_info where mov_info like '%''' + cate + '''%' and mov_info like '%''' + time + '''%' order by mov_date desc'''
            total_all = cur.execute(total_all)
            total_all = int(total_all.fetchone()[0])
            print(total_all)
            page = int(request.args.get('page', 1))
            pager = Pager(page, total_all)
            pages = pager.get_pages()
            skip = (page - 1) * 24
            data_to_show = mov_info_all[skip:skip + 24]
            len_to_show = len(data_to_show)
            # print(data_to_show)
            return render_template('catalog.html',
                                   url=url,
                                   pages=pages,
                                   data_to_show=data_to_show,
                                   len_to_show=len_to_show)
Example #4
0
def index():
    page = int(request.args.get('page', 1))
    count = 300
    data = range(count)
    pager = Pager(page, count)
    pages = pager.get_pages()
    skip = (page - 1) * current_app.config['PAGE_SIZE']
    limit = current_app.config['PAGE_SIZE']
    data_to_show = data[skip: skip + limit]
    return render_template('index.html', pages=pages, data_to_show=data_to_show)
Example #5
0
def index():
    page = int(request.args.get('page', 1))
    count = len(word_list)
    data = sorted(word_list)
    pager = Pager(page, count)
    pages = pager.get_pages()
    skip = (page - 1) * current_app.config['PAGE_SIZE']
    limit = current_app.config['PAGE_SIZE']
    data_to_show = data[skip:skip + limit]
    return render_template('slovar.html',
                           pages=pages,
                           data_to_show=data_to_show)
Example #6
0
def catalog():
    with get_db_con() as con:
        cur = con.cursor()

        mov_info_all = "select * from Mov_info"

        mov_info_all = cur.execute(mov_info_all)
        mov_info_all = list(mov_info_all.fetchall())

        action = "select * from mov_info where mov_info like '%액션%' order by mov_date desc"

        mov_info_action = cur.execute(action.format('action'))
        mov_info_action = list(mov_info_action.fetchall())

        romance = "select * from mov_info where mov_info like '%로맨스%' order by mov_date desc"

        mov_info_romance = cur.execute(romance.format('romance'))
        mov_info_romance = list(mov_info_romance.fetchall())

        horror = "select * from mov_info where mov_info like '%공포%' order by mov_date desc"

        mov_info_horror = cur.execute(horror.format('horror'))
        mov_info_horror = list(mov_info_horror.fetchall())

        ani = "select * from mov_info where mov_info like '%애니메이션%' order by mov_date desc"

        mov_info_ani = cur.execute(ani.format('ani'))
        mov_info_ani = list(mov_info_ani.fetchall())

        url = 'http://www.kobis.or.kr/'

        total_all = 'select count(*) from mov_info'
        total_all = cur.execute(total_all)
        total_all = int(total_all.fetchone()[0])

        page = int(request.args.get('page', 1))
        pager = Pager(page, total_all)
        pages = pager.get_pages()
        skip = (page - 1) * 24
        data_to_show = mov_info_all[skip:skip + 24]
        len_to_show = len(data_to_show)
        # print(data_to_show)
        return render_template('catalog.html',
                               url=url,
                               mov_info_action=mov_info_action,
                               mov_info_romance=mov_info_romance,
                               mov_info_horror=mov_info_horror,
                               mov_info_ani=mov_info_ani,
                               pages=pages,
                               data_to_show=data_to_show,
                               len_to_show=len_to_show)
def twitter_report_index():

    session['logged_in'] = True

    if session.get('logged_in'):
        # 0- negative, 1- postive, 2 - neutral
        sentiment_type_id = 1

        if request.method == 'POST' and 'click_button_id' in request.form:
            sentiment_type_id = request.form['click_button_id']
            session['twitter_filter_type'] = sentiment_type_id

        if session.get('twitter_filter_type'):
            sentiment_type_id = session.get('twitter_filter_type')

        page = int(request.args.get('page', 1))
        count = ReportModel.get_twitter_article_count(
            sentiment_type_id, session.get('user_id'))[0][0]

        if count == 0:
            msg = 'No records found.'
            return render_template('reports/twitter_report_index.html',
                                   msg=msg)
        else:
            bar = create_twitter_plot("Pie")

            data = range(count)
            pager = Pager(page, count)
            pages = pager.get_pages()
            offset = (page - 1) * current_app.config['PAGE_SIZE']
            limit = current_app.config['PAGE_SIZE']
            twitter_news_records = ReportModel.get_twitter_article(
                limit, offset, sentiment_type_id, session.get('user_id'))
            return render_template('reports/twitter_report_index.html',
                                   pages=pages,
                                   twitter_news_records=twitter_news_records,
                                   plot=bar)

    else:
        return redirect(url_for('login'))
Example #8
0
def catalogWS():
    if request.method == 'GET':
        keyword = request.values["keyword"]
        len_to_show = 24
        with get_db_con() as con:
            cur = con.cursor()

            mov_info_all = '''select * from Mov_info  where mov_name_kor like '%''' + keyword + '''%' or mov_name_eng like '%''' + keyword + '''%' or mov_director like '%''' + keyword + '''%' or mov_actor like '%''' + keyword + '''%' order by mov_date desc'''

            mov_info_all = cur.execute(mov_info_all)
            mov_info_all = list(mov_info_all.fetchall())

            url = 'http://www.kobis.or.kr/'

            total_all = '''select count(*) from mov_info where mov_name_kor like '%''' + keyword + '''%' or mov_name_eng like '%''' + keyword + '''%' or mov_director like '%''' + keyword + '''%' or mov_actor like '%''' + keyword + '''%' order by mov_date desc'''
            total_all = cur.execute(total_all)
            total_all = int(total_all.fetchone()[0])

            if total_all >= 24:
                page = int(request.args.get('page', 1))
                pager = Pager(page, total_all)
                pages = pager.get_pages()
                skip = (page - 1) * 24
                data_to_show = mov_info_all[skip:skip + 24]
                len_to_show = len(data_to_show)
            else:
                pages = [1]
                data_to_show = mov_info_all
                len_to_show = len(data_to_show)
            # print(len(data_to_show))
            # print(data_to_show)
            return render_template('catalog.html',
                                   url=url,
                                   pages=pages,
                                   data_to_show=data_to_show,
                                   len_to_show=len_to_show)