Perl/Raku 简洁的网络服务器一句话?

uxe*_*xer 7 perl webserver raku one-liner

如果没有的话,是否有任何简洁的单行文字可以快速提供页面或目录index.html?像这样的东西:

python3 -m http.server
Run Code Online (Sandbox Code Playgroud)

找不到Raku单线。
比较Perl来自https://gist.github.com/willurd/5720255https://github.com/imgarylai/awesome-webservers的内容:

plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");' -p 8000
Run Code Online (Sandbox Code Playgroud)
perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
Run Code Online (Sandbox Code Playgroud)

使用前安装它们(无需额外安装Python):

cpan Plack
cpan HTTP::Server::Brick
Run Code Online (Sandbox Code Playgroud)

Plack引入了大量的依赖项,因此我没有继续安装,并且HTTP::Server::Brick由于测试失败而没有安装在我的计算机上。

Perl和两者Raku通常都被认为在单行句中很好用,并且旨在提供 DWIM: “根据上下文尝试做正确的事情”“猜测......提供虚假输入时预期的结果”

所以我希望他们——尤其是现代和富有的Raku——能够提供一个与Python.
或者我错过了什么?
如果缺少该功能,是否有计划?
如果缺乏且不实施,为什么?

Dav*_*oss 8

我喜欢http_thishttps_this也可用)。

有一个令人讨厌的缺点,它目前不支持index.html- 但我有一个待处理的拉取请求来解决这个问题。

另一方面,这些程序依赖于 Plack,所以也许您宁愿寻找其他地方。


p6s*_*eve 8

Raku Cro 需要一根线来安装:

zef install --/test cro

然后设置并运行:

cro stub http hello hello && cro run

来自https://cro.services/docs/intro/getstarted

假设您想要提供项目子目录中的所有文件,例如 hello/httpd,然后将标准hello/lib/Routes.pm6文件调整为:

  1 use Cro::HTTP::Router;
  2 
  3 sub routes() is export {
  4     route {
  5         get -> *@path {
  6             static 'httpd', @path;
  7         }
  8     }
  9 }
Run Code Online (Sandbox Code Playgroud)

cro run查找文件更改并自动重新启动服务器

index.html工作正常

ln -s如果您的目录位于项目树之外,我建议使用符号链接

  • 好的,我在这里给出一行行 ```raku -e 'shell("zef install --/test cro && cro stub http hello hello && cro run")';``` ;-) (2认同)