是什么让 `curl http://localhost:8000/initdb` 返回 `init database` 和 `curl http://localhost:8000/widget` 返回 404?

问题描述 投票:0回答:1

我正在遵循 使用容器进行开发#获取并运行示例应用程序 | 中的教程Docker 文档。在第 6 步,我得到的不是空的

[]
JSON 字符串,而是:

curl http://localhost:8000/initdb
init database

curl http://localhost:8000/widget
<!doctype html>
<html lang=en>
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

这是为什么呢?这是

docker ps -a

的结果
CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS                    NAMES
2a87fc863140   python-docker-dev   "/bin/sh -c 'python …"   6 minutes ago    Up 6 minutes    0.0.0.0:8000->5000/tcp   rest-server
7d7eb37dc40e   postgres            "docker-entrypoint.s…"   12 minutes ago   Up 12 minutes   0.0.0.0:5432->5432/tcp   db
database docker curl localhost
1个回答
0
投票

您可以尝试使用Web浏览器访问两个端点来调试问题。如果您可以在 Web 浏览器中访问 /initdb 端点,但不能访问 /widget 端点,则问题很可能出在应用程序本身。如果您无法访问任一端点,则问题很可能出在您的本地计算机或网络配置上。

© www.soinside.com 2019 - 2024. All rights reserved.