@app.before_request
def check_login():
if request.path == ‘/login’:
return None
user_info = session.get(‘user_info’)
if not user_info:
return redirect(‘/login’)
@app.route(‘/login’,methods=[‘GET’,‘POST’])
def login():
if request.method == “GET”:
return render_template(‘login.html’)
else:
user = request.form.get(‘user’)
nid = str(uuid4())
USER_QUEUE_DICT[nid] = Queue()
session[‘user_info’] = {‘nid’:nid, ‘user’:user }
return redirect(‘/index’)
@app.route(‘/index’)
def index():
return render_template(‘index.html’,user_list = UUUU)
@app.route(‘/query’)
def query():
“”“每个用户查询最新投票信息”“”
ret = {‘status’:True,‘data’:None}
current_user_nid = session[‘user_info’][‘nid’]
queue = USER_QUEUE_DICT[current_user_nid]
try:
# {‘uid’:1, ‘count’:6}
ret[‘data’] &