perl/raku简洁的网络服务器单线?
如果没有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
由于测试失败而不会在我的计算机上安装。
perl
和raku
通常被认为在单线上是好的,旨在交付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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我喜欢 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.
raku cro需要安装一行:
zef安装 - /test CRO
,然后进行设置和运行:
cro ub stub http http hello hello hello hello&&& cro run
来自
”假设您要在项目子目录中使用所有文件,例如Hello/httpd,然后调整标准
hello/lib/doutes.pm6
文件: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:cro run
looks for file changes and will auto restart the serverindex.html
works fineI suggest a symbolic link
ln -s
if your dir is outside the project tree将问题的网络服务器部分放在一边,Python和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.
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.