python - 从外部访问python开发服务器

标签 python django

我无法从外部访问 python 开发服务器,我的机器上运行着一个非常小的 django 项目,现在我想让同一局域网中的计算机能够访问它,但是做不到。

我的机器上没有运行防火墙。有解决办法吗?

最佳答案

你是如何运行服务器的?
你试过这样的事情吗?

manage.py runserver 0.0.0.0:8080

来自 the documentation :

Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0.

0.0.0.0 表示:绑定(bind)到这台计算机支持的所有 IP 地址。所以,作为 TheSingularity says ,然后您就可以通过输入通常以 192.168.* 开头的私有(private) IP 地址来访问您的 Django 应用程序;无法从 Internet 访问。

关于python - 从外部访问python开发服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4073977/

相关文章:

python - 如何使用 jupyter Notebook 代码创建可执行文件?

python - Django 添加管理命令而不安装为应用程序

django - Django结合了DetailView和FormView

python - 具有异步任务和redis的django中的线程安全

python - 使用正则表达式仅捕获列表中的第一个元素(可以是多个,但不能一个接一个

python - Pandas 选择符合我标准的特定行之前和之后的特定行

python - 扭曲的 python 日志记录问题/困惑?

python - Django gettext 和 gettext_lazy 均以相同名称导入

python-docx: 添加来自网络的图片

python - 配置不当 : The SECRET_KEY setting must not be empty error after editing django auth pipeline