我正在尝试将我的烧瓶应用程序部署到Bluemix,它由Bluemix Python Flask BuildPack配置,它不是自定义构建。
@app.route('/run', methods=['GET','POST'])
def stockModuleRunner():
stockCode = request.args.get("stock_code","")
# Store the reference, in case you want to show things again in standard output
old_stdout = sys.stdout
# This variable will store everything that is sent to the standard output
result = StringIO()
sys.stdout = result
# Here we can call anything
# Here we can call anything we like, like external modules, and everything that they will send to standard output will be stored on "result"
r = Resilience.Resilience()
r.main(stockCode)
# Redirect again the std output to screen
sys.stdout = old_stdout
# Then, get the stdout like a string and process it!
result_string = result.getvalue()
print(result_string)
#r = Resilience.Resilience()
#r.main(stockCode)
resp = Response("<html><pre>"+result_string+"</pre></html>")
resp.headers['content-type'] = 'text/html; charset=utf-8'
return
我将响应的内容类型设置为text / html。但它在Bluemix中不起作用,而它在我的本地环境中起作用。在Bluemix中,它自动更改为text / xml。我通过chrome开发人员工具的网络选项卡确认了它。我得到了如下错误。根据谷歌搜索的结果,我发现它是一种xml解析错误。你对这个问题有什么看法吗?
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.