Commit 39b5424b authored by ale's avatar ale

make the receiver app compatible with wsgi-app-installer

parent 9509a338
......@@ -10,7 +10,6 @@ import redis
from flask import Flask, request, abort, g
app = Flask(__name__)
app.config.from_pyfile('config.py')
def get_redis_connection():
......@@ -33,23 +32,27 @@ def receive():
abort(400)
p = g.redis.pipeline(transaction=False)
per_user = {}
#per_user = {}
for user, results in data.iteritems():
key = 'virus:%s' % user
p.ltrim(key, 0, 0)
#p.ltrim(key, 0, 0)
for r in results:
p.lpush(key, r)
per_user[user] = len(results)
#per_user[user] = len(results)
# Save some incremental stats with per-user infection counts.
#new_ptr = 'virus_stats:%f' % time.time()
#for user, count in per_user.iteritems():
# p.hset(new_ptr, user, count)
#p.set('virus_stats:head', new_ptr)
new_ptr = 'virus_stats:%f' % time.time()
for user, count in per_user.iteritems():
p.hset(new_ptr, user, count)
p.set('virus_stats:head', new_ptr)
p.execute()
return ['ok']
def create_app():
# The env variable name is compatible with wsgi-app-installer.
app.config.from_envvar('APP_CONFIG', silent=True)
return app
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment