python - Streaming data with Flask raise RuntimeError: working outside of request context
怪我咯
怪我咯 2017-04-17 11:44:53
0
0
863

原问题: Streaming data with Python and Flask 我需要把这段代码做下改动,如下所示,但这段代码一直报错:raise RuntimeError: working outside of request context 初看是因为 request 变量没有传到 ggg1() 函数里面去,我调试了好久也没找出原因。。。 哪位同学能看懂啥原因的,解释下怎么改,以及为啥? 先谢过了~

代码如下:

@app.route('/username', methods=['GET', 'POST']) def index(): req =request print req print "111------------" + req.method + "\n" def ggg1(req): print req # the req not my pass into the req.... print "444------------" + req.method + "\n" if req.method == 'POST': if request.form['username']: urlList = request.form['username'].splitlines() i = 0 for url in urlList(): i += 1 resultStr = chkListPageContent(url, getUrlContent(url), "script") print i, resultStr yield i, resultStr print req print "222------------" + req.method + "\n" return Response(stream_template('index.html', data=ggg1(req)))
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复 (0)
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!