perl/raku简洁的网络服务器单线?

发布于 2025-02-08 14:36:17 字数 1417 浏览 2 评论 0原文

如果没有index.html,是否有任何简洁的单线供快速提供页面或目录?类似的东西:

python3 -m http.server

找不到raku单线。
比较perl一个,取自 https://gist.github.com/willurd/ 5720255 https://github.com/imgarylai/imgarylai/awsome-weashes-weashes-weashes-weashervers

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

install它们在使用之前(python>没有其他安装):

cpan Plack
cpan HTTP::Server::Brick

Plack拉动了大量的依赖项,因此我没有进行安装,http :: http :: Server :: Brick由于测试失败而不会在我的计算机上安装。

perlraku通常被认为在单线上是好的,旨在交付dwim: “尝试做正确的事,取决于上下文, “猜猜...提供伪造时的结果是“提供的结果”

,我期望他们 - 尤其是现代Rich Raku - 使用python。 还是我错过了什么?
如果功能缺乏,是否计划?
如果缺乏且不实现,为什么?

Are there any concise one-liners for quick serving of pages or directories if no index.html? Something like this:

python3 -m http.server

Couldn't find a Raku one-liner.
Compare Perl ones, taken from https://gist.github.com/willurd/5720255 and https://github.com/imgarylai/awesome-webservers :

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

Install them prior to use (no additional installs with Python):

cpan Plack
cpan HTTP::Server::Brick

Plack pulls in a gajillion of dependencies so I didn't proceed with installation, and HTTP::Server::Brick doesn't install on my machine as its tests fail.

Both Perl and Raku are generally considered to be good in one-liners, and are meant to deliver DWIM:
"try to do the right thing, depending on the context",
"guess ... the result intended when bogus input was provided"

So I'd expect them - especially modern and rich Raku - to provide a webserver one-liner on par in simplicity with Python.
Or have I missed something?
If the feature lacks, is it planned?
If lacks and not-to-be-implemented, why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稚然 2025-02-15 14:36:17

我喜欢 http_this https_this 也可以使用)。

有一个令人讨厌的缺点,因为它当前不支持index.html - 但是我有一个拉请求待定来解决。

另一方面,这些程序依赖于种头,所以也许您宁愿在其他地方看。

I like http_this (https_this is also available).

There's an annoying shortcoming in that it doesn't currently support index.html - but I have a pull request pending to fix that.

On the other hand, these programs rely on Plack, so maybe you'd rather look elsewhere.

z祗昰~ 2025-02-15 14:36:17

raku cro需要安装一行:

zef安装 - /test CRO

,然后进行设置和运行:

cro ub stub http http hello hello hello hello&&& cro run

来自

”假设您要在项目子目录中使用所有文件,例如Hello/httpd,然后调整标准hello/lib/doutes.pm6文件:

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

cro Run寻找寻找文件更改,并将自动重新启动服务器

index.html工作正常,

建议符号链接ln -s如果您的DIR在项目树外面

Raku Cro needs one line to install:

zef install --/test cro

And then one to setup and run:

cro stub http hello hello && cro run

From https://cro.services/docs/intro/getstarted

Let's say you want to serve all the files in a project subdirectory e.g. hello/httpd, then tweak the standard hello/lib/Routes.pm6 file to this:

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

cro run looks for file changes and will auto restart the server

index.html works fine

I suggest a symbolic link ln -s if your dir is outside the project tree

小伙你站住 2025-02-15 14:36:17

将问题的网络服务器部分放在一边,Python和Perl的哲学有所不同。他们俩都是做事的好方法,并且每种都吸引了另一种人群。

  • Python是“包括电池”,因此它是其标准库中许多事物的重量级分布。即使您从未使用过大部分,也有更多的开箱即用。
  • Perl试图分发足够的时间,以便您安装所需的模块。这样,您可以选择比Perl选择分发的东西更新鲜或更新的东西。

现在,对于Web服务器,您可能会喜欢Mojolicious。它主要是独立的(或主要依赖于核心模块),因此安装更容易。您提到的链接有Mojolicious :: Lite示例。

Putting aside the webserver portion of your question, Python and Perl differ in their philosophies. Both of them are perfectly fine ways of doing things, and each appeals to a different sort of crowd.

  • Python is "batteries included", so it's a heavyweight distribution of many things in its standard library. There's more right out of the box, even if you never use most of it.
  • Perl tries to distribute just enough for you to install the modules that you decide that you need. That way, you can choose something that is fresher or newer than the thing that Perl chose to distribute.

Now, for the webserver, you may like Mojolicious. It's mostly self-contained (or relies on mostly core modules) so it's an easier install. The links you mentioned have Mojolicious::Lite examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文