弹幕 报错 后台配置项错误
来源:11-4 .电影弹幕
青丘图图
2017-09-01
写回答
1回答
-
rustgopy
2017-09-02
同学,你好,后端配置可能有问题,你检查下后端代码是否有问题。
@home.route("/tm/", methods=["GET", "POST"]) def tm(): import json if request.method == "GET": #获取弹幕消息队列 id = request.args.get('id') key = "movie" + str(id) if rd.llen(key): msgs = rd.lrange(key, 0, 2999) res = { "code": 1, "danmaku": [json.loads(v) for v in msgs] } else: res = { "code": 1, "danmaku": [] } resp = json.dumps(res) if request.method == "POST": #添加弹幕 data = json.loads(request.get_data()) msg = { "__v": 0, "author": data["author"], "time": data["time"], "text": data["text"], "color": data["color"], "type": data['type'], "ip": request.remote_addr, "_id": datetime.datetime.now().strftime("%Y%m%d%H%M%S") + uuid.uuid4().hex, "player": [ data["player"] ] } res = { "code": 1, "data": msg } resp = json.dumps(res) rd.lpush("movie" + str(data["player"]), json.dumps(msg)) return Response(resp, mimetype='application/json')
00
相似问题