我正在Google App Engine上制作应用程序,并希望在本地运行该应用程序并通过Postman测试请求。我在本地启动服务器:
python3 main.py
然后我得到以下信息:
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 257-782-471
我可以使用“ Web预览”和“在端口8080上预览”来完美查看应用程序。 当我单击链接“ http://127.0.0.1:8080/”时,它会将我重定向到有效的“ https://8080-dot-12856039-dot-devshell.appspot.com/?authuser=0&environment_name=default”,但我无法在邮递员中访问它。
当我在网络浏览器或邮递员中输入http://127.0.0.1:8080/时,没有响应,并且出现该网站无法访问错误
当我部署该应用程序时,URL和所有内容都可以正常运行,但是我不想每次希望检查请求时都部署整个应用程序。我只想运行它并在本地访问它。
有人知道我在做什么错吗?
答案 0 :(得分:0)
根据您提供的信息,我假设您正在Cloud Shell中运行python3 main.py
命令。
然后,当您单击Web Preview
或Preview on port 8080
时,这将创建一条从Cloud Shell到虚拟机的SSH隧道,该虚拟机托管着幕后资源,并且此过程使您能够通过导航到127.0.0.1:8080
或 https://8080-dot-12856039-dot-devshell.appspot.com/?authuser=0&environment_name=default
来连接和测试应用。
简而言之,如果您要发出GET
或POST
请求,则可以在Cloud Shell中打开另一个选项卡并使用curl以实现与Postman类似的行为。使用Postman,您正试图从外部访问,而您无权访问URL。
此信息在Cloud Shell documentation中进行了解释。