Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在GCE实例上运行web应用程序_Python_Flask_Debian_Virtualenv_Google Compute Engine - Fatal编程技术网

Python 在GCE实例上运行web应用程序

Python 在GCE实例上运行web应用程序,python,flask,debian,virtualenv,google-compute-engine,Python,Flask,Debian,Virtualenv,Google Compute Engine,在本教程之后,我将学习如何使用virtualenv和flask 我创建了一个小型的helloworldweb应用程序并执行了它:/app.py。 这导致: * Running on http://127.0.0.1:5000/ * Restarting with reloader 但是当我打开浏览器并输入http://:5000时,我没有看到hello world,而是看到: 无法连接到:5000 我遗漏了什么?此消息清楚地说明了您遗漏了什么: Running on http://127.0.

在本教程之后,我将学习如何使用
virtualenv
flask

我创建了一个小型的
helloworld
web应用程序并执行了它:
/app.py
。 这导致:

* Running on http://127.0.0.1:5000/
* Restarting with reloader
但是当我打开浏览器并输入http://:5000时,我没有看到hello world,而是看到:

无法连接到:5000


我遗漏了什么?

此消息清楚地说明了您遗漏了什么:

Running on http://127.0.0.1:5000/
服务器仅侦听
localhost
地址,因此它不会看到来自其他计算机的连接。如果要让服务器在公共界面上侦听,则需要更改
app.run()
行,如下所示:

app.run(host = '0.0.0.0', debug = True)

http://:5000
是打字错误吗?如果没有,请尝试
http://127.0.0.1:5000/
。如果您是Flask新手,另一个很好的教程是:@Seberius yep这是一个打字错误,谢谢,我的web应用程序运行在GCE上,因此试图从我的macbook调用它,我将127.0.0.1替换为GCE instanceOk的外部ip,这是一个部署,根据标题可以理解。不幸的是,我没有GCE的经验。您可能希望更新此问题,以包括您的应用程序的配置,以帮助其他人解决此问题。一旦我投入生产,配置服务的正确方式是什么?在生产框中,您不想使用Flask自己的web服务器,您需要使用更健壮的服务器,如nginx或apache。Flask提供了有关为生产配置这些和其他web服务器的信息。我刚刚发现您是我下面教程的作者,非常好的教程,谢谢!!!