Flask / python路由在本地运行,但在GCP上崩溃

时间:2018-08-10 15:39:55

标签: python flask google-cloud-platform subprocess

我想知道为什么以下Flask / Python路由在本地运行,但在GCP(Google云平台)上却出现内部服务器错误?

在添加路由“ / test /”之前,我已部署到GCP,并且能够访问所有路由。

在包含路由'/ test /之后,我能够访问所有期望'/ test /'路由的路由,这将引发内部服务器错误。

任何建议都将不胜感激。 谢谢。

@app.route('/test/')
def test():
    p = subprocess.Popen(["coverage", "run", "--branch", "test.py"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            stdin=subprocess.PIPE)
    out, err = p.communicate()
    output=err+out
    output = output.decode("utf-8")

    return render_template('test.html', output = "<br/>".join(output.split("\n")))

test.html

<html>
    <head> </head>
    <body>
        <pre><code>{{ output }}</code></pre>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

coverage必须包含在requirements.txt文件中,以便可以将其安装在GCP环境中。

相关问题