def get(this, **x): # Проверка параметров check_params(x, (('search', True, str), )) # Обработка messages = search_global(x['search'], 100) posts = get_styled(messages) graph = timeline(messages) # Ответ res = { 'posts': posts, 'graph': graph, } # this.socketio.emit('trends', res, namespace='/main') return res
def trends(x): # global thread # with thread_lock: # if thread is None: # thread = sio.start_background_task(target=background_thread) sid = request.sid timestamp = time.time() # Отслеживание req = { 'time': timestamp, 'user': x['token'], 'method': 'trends', 'params': { 'search': x['search'] }, } # print('TREND', '1', x['search']) messages = search_global(x['search'], 100) print('TREND', '2') posts = get_styled(messages) print('TREND', '3') graph = timeline(messages) print('TREND', '4') # Ответ res = { 'posts': posts, 'graph': graph, } sio.emit('trends', res, room=sid, namespace='/main')
def search_styled(req, count): res = search_global(req, count) return get_styled(res)
def search_xml(req, count): res = search_global(req, count) return get_xml(res, req)
def search_json(req, count): res = search_global(req, count) return get_json(res, req)
def search_json(req, count): res = search_global(req, count) return get_json(res, req) def search_xml(req, count): res = search_global(req, count) return get_xml(res, req) def search_styled(req, count): res = search_global(req, count) return get_styled(res) if __name__ == '__main__': inp = 'Керчь' req = search_global(inp, 5) res = get_xml(req, inp) with open('data/res.xml', 'w') as file: print(res, file=file) res = get_json(req, inp) with open('data/res.json', 'w') as file: print(res, file=file) res = get_styled(req) print(res)