Пример #1
0
def stats():
	queue=[tweets.s("tweets_{}.txt".format(i)) for i in xrange(0,20)]
        g = group(queue)
        res = g()
        while res.ready()=="False":
                time.slee(3)
        dicts = res.get()
        counter = Counter()
        for dic in dicts:
                counter.update(dic)
	dic = dict(counter)
 
 	fig = Figure()
	ax = fig.add_subplot(1,1,1)
	x=[]
	for i in range(len(dic)):
		x.append(i)

	ax.bar(x, dic.values(),width=0.8)
	#plt.xticks(range(len(dic)),dic.keys())
	#plt.title ="Data Visualization"
	#plt.xlabel ="words"
	#plt.ylabel = "Counts"

	canvas = FigureCanvas(fig)
	output =StringIO.StringIO()
	canvas.print_png(output)
	response = make_response(output.getvalue())
	response.mimetype = 'image/png'
	return response
Пример #2
0
def get_tweet():

    queue = [tweets.s("tweets_{}.txt".format(i)) for i in xrange(0, 20)]
    g = group(queue)

    res = g()
    while res.ready() == "False":
        time.slee(3)
    dicts = res.get()
    counter = Counter()
    for dic in dicts:
        counter.update(dic)

    return jsonify(dict(counter))