The*_*zer 0 python django visual-studio-code vscode-debugger
我无法连接到在 vs-code 生成的容器内运行的 django 进程。一切似乎都正常,我收到服务器的启动消息,但是当连接到 localhost:8000 时,我没有得到任何响应...
启动容器时我收到已发布的端口消息:
发布的端口:8000/tcp -> 127.0.0.1:8000
启动 launch.json 调试时也是一个干净的开始
系统检查未发现任何问题(0 已静音)。2019 年 10 月 13 日 - 17:45:05 Django 版本 2.2.6,使用设置 'fpl-django.settings' 在http://127.0.0.1:8000/启动开发服务器使用 CONTROL-C 退出服务器。
为什么我无法访问 localhost:8000 上的网站?
devcontainer.json:
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../docker/dev/python/Dockerfile",
// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [
// Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker for details.
// "-v","/var/run/docker.sock:/var/run/docker.sock",
// Uncomment the next line if you will be using a ptrace-based debugger like C++, Go, and Rust.
// "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
// You may want to add a non-root user to your Dockerfile. On Linux, this will prevent
// new files getting created as root. See https://aka.ms/vscode-remote/containers/non-root-user
// for the needed Dockerfile updates and then uncomment the next line.
// "-u", "vscode"
"--network",
"fpl-django_default"
],
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.linting.enabled": true
},
// Uncomment the next line if you want to publish any ports.
"appPort": [
8000
],
// Uncomment the next line to run commands after the container is created - for example installing git.
// "postCreateCommand": "apt-get update && apt-get install -y git",
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-python.python",
]
}
Run Code Online (Sandbox Code Playgroud)
启动.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"django": true
}
]
}
Run Code Online (Sandbox Code Playgroud)
manage.py runserver尝试使用此参数运行: 0.0.0.0:8000,这将告诉您的应用程序侦听来自任何主机的请求。就像这样:
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"0.0.0.0:8000",
"--noreload",
"--nothreading"
],
"django": true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1215 次 |
| 最近记录: |