-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
参考:
- https://docs.python.org/zh-cn/3/library/http.server.html
- https://developer.mozilla.org/zh-CN/docs/Learn/Common_questions/set_up_a_local_testing_server
一、局域网内访问静态网页
如果你只需要一个简单的 Web Server ,场景例如:在局域网内使用手机测试访问电脑上的HTML静态网页。
此时,无需下载并配置 Nginx 或 Apache 或 ISS 这些复杂的 HTTP 服务程序。
安装 Python3 后,只需要一行命令就可以完成一个简单的内建 HTTP 服务器:
$ python -m http.server 8000 # 默认使用8000端口,也可以使用其他端口此时,在局域网内的其他设备上的浏览器,输入 192.168.31.57:8000 (注意这里请使用你自己的 IP 和端口)即可访问到 ~/code/cxff 目录下的 index.html 网页(配合”花生壳等内网穿透工具“还可以实现公网访问):