0

我需要设置一个下载 HTTP 服务器,我不想安装 Apache。

我可以使用HTTP::Server::Simple作为下载 http 服务器吗?你能给我一些示例代码吗?

或者是否有其他 CPAN 模块可以帮助我快速简单地设置下载 HTTP 服务器?

sub download {
 my $cgi  = shift;   # CGI.pm object
 return if !ref $cgi;

 my $file = $cgi->param('file'); #file=test.tar.gz
 $file="/var/download/$file";    #file=/var/download/test.tar.gz 

 # send this file
}
4

3 回答 3

4

与 mugen kenichi 对 Plack 的回答相同:

plackup -MPlack::App::Directory -e'Plack::App::Directory->new({ root => "." })->to_app'

这已经处理了 David-SkyMesh 评论的内容,并且很容易从命令行混合 Authn/Authz。可以通过添加-s Starman.

于 2012-04-09T09:27:00.350 回答
2

您还可以使用App::HTTPThis。安装后:

http_this dir_name

可能没有比这更容易的了。事实上,如果您已经在要导出的目录中,则可以跳过 dir_name 参数。

于 2012-04-09T15:34:57.413 回答
-1

As stated in the comments this is no trivial problem. However, if i need a quick and simple server to provide files I usualy do

python -m SimpleHTTPServer

in the directory I want to serve. It starts a webserver at 0.0.0.0:8000 and you can point your browser there to download the files.

I do not know if a similar one line solution exists for perl but I guess it does not get any more simple than that.

于 2012-04-09T08:01:50.980 回答