Example #1
0
def worker():
    i = 0
    while True:
        item = q.get()
        if item is None:
            print("Break ! cuz item is None")
            break
        api = Summarizer(item[0], item[1], "keys")
        api.keyToVideo()
        i += 1
        print("-----Task{0}----".format(i))
        q.task_done()
def test_run():
    if path.exists("keys"):
        api = Summarizer("Manchester", "manchester", "keys")
        assert api.keyToVideo() == 0
    else:
        with open("data.json", "r") as f:
            return json.load(f)
def post():
    data = {}
    data['keyword'] = ''
    data['get_status'] = ''
    data['get_video'] = ''
    try:
        app.mykeyword = request.form['keyword']
        data['keyword'] = app.mykeyword
        oldapi = Summarizer(data['keyword'], data['keyword'], "keys")
        app.mystatus = oldapi.keyToVideo()
        data['get_status'] = base_url + 'status/' + data['keyword']
        data['get_video'] = base_url + 'video/' + data['keyword']
        return jsonify(keyword=data['keyword'],
                       get_status=data['get_status'],
                       get_video=data['get_video'])
    except:
        data['keyword'] = 'breaking'
        Summarizer('breaking', 'breaking', "keys").keyToVideo()
        data['get_status'] = base_url + 'status/' + data['keyword']
        data['get_video'] = base_url + 'video/' + data['keyword']
        return jsonify(keyword=data['keyword'],
                       get_status=data['get_status'],
                       get_video=data['get_video'])