写前端页面的时候,忍不住想看一下写成什么样了,所以会用到。
使用php时,我们可以这样写:
# php -S ip:端口 -t 站点根目录
# 如:
php -S 127.0.0.1:80 -t /tmp/www
不加 -t 参数,默认为当前文件夹。
使用python时,这样写就可以了:
python -m http.server --bind 127.0.0.1 -d /tmp/www 80
# --bind 为绑定ip
# -d 为指定网站根目录,不加这个参数,默认为当前文件夹
# 80为http服务的端口,不指定时默认为8000
# 可以使用 python -m http.server -h 查看详细使用说明