为当前目录提供服务的简单文件服务器 [英] Simple file server to serve current directory

查看:48
本文介绍了为当前目录提供服务的简单文件服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的垃圾箱,我可以在 shell 中启动它并让它服务于当前目录(最好不是 ..),可能还有一个 -p 用于指定端口.因为它应该是一个开发服务器,所以默认情况下它应该只允许来自本地主机的连接,也许可以选择另外指定.越简单越好.

不确定在这里使用哪些标签.

解决方案

python3 -m http.server

或者如果您不想使用默认端口 8000

python3 -m http.server 3333

或者如果您只想允许来自本地主机的连接

python3 -m http.server --bind 127.0.0.1

请参阅文档.>


等效的 Python 2 命令是

python -m SimpleHTTPServerpython -m SimpleHTTPServer 3333

没有 --bind 选项.

请参阅 Python 2 文档.

I'm looking for a dead simple bin that I can launch up in the shell and have it serve the current directory (preferably not ..), with maybe a -p for specifying port. As it should be a development server, it should by default allow connections from localhost only, maybe with an option to specify otherwise. The simpler, the better.

Not sure which tags to use here.

解决方案

python3 -m http.server

or if you don't want to use the default port 8000

python3 -m http.server 3333

or if you want to allow connections from localhost only

python3 -m http.server --bind 127.0.0.1

See the docs.


The equivalent Python 2 commands are

python -m SimpleHTTPServer

python -m SimpleHTTPServer 3333

There is no --bind option.

See the Python 2 docs.

这篇关于为当前目录提供服务的简单文件服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆