Live data from Hacker News

Show HN: Redbean – Single-file distributable web server

justine.lol

81–90 of 264 posts

Re: Show HN: Redbean – Single-file distributable web server

#81
post #55
post #45

Odd, I'm getting $ ./printimage.com image.jpg run-detectors: unable to find an interpreter for ./printimage.com

Author here. That error happens if you have binfmt_misc enabled. The solution is simple: sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" I intend to upstream a patch with the Linux kernel so it can do this automatically. If any kernel devs are reading, please email me!

Does it work on cheap Xen vps? Because "/proc/sys/fs/binfmt_misc/register" looks absent from mine.

Re: Show HN: Redbean – Single-file distributable web server

#82
post #47

It's a neat coincidence that this is on at the same time as an article about CP/M, because I think there could be some overlap in the programs that would be a good fit for cosmopolitan. Sure, there's server appliances like this, and I hope someone makes a neat services wrapper to abstract at least some platform's intricacies so you can do a "cosmo-service up redbean" on BSD/Linux/Windows. But coming back to CP/M, the…

Author here. We're living in the most exciting time for developing terminal applications. When Microsoft unexpectedly added support for VT100 and XTERM codes to CMD.EXE it totally changed the equation and ANSI became universal for the first time. Blinkenlights is an example of a TUI application I created using Cosmopolitan and it literally works everywhere. https://justine.lol/blinkenlights/index.html You don't need curses. All that's needed is an ioctl() call which flips a bit in termios. Cosmopolitan polyfills that across operating systems. Another cool example of a demo app is this conway's game of life tui gui: https://justine.lol/apelife/index.html

Re: Show HN: Redbean – Single-file distributable web server

#83
post #10

I just spent 30 minutes reading about this. I'm so shocked that I'm logging in to comment after 5 years of lurking. Justine has built a c library that allows you compile a binary once and have it run it on any os or baremetal. The SAME binary. Quite frankly, that sentence doesn't even make sense to me. Check out https://storage.googleapis.com/justine/cosmopolitan/index.ht... As far as I'm concerned, this is literal m…

That malware for OS X that does nothing (so far) from the news earlier this week also has one multi-arch binary for all modern Apple notebook architectures (AMD64 and ARM64)

Re: Show HN: Redbean – Single-file distributable web server

#84
post #58
post #56

Earlier quoted context omitted.

After adding a new file with WinRAR, I get: EINVAL/err=87/errno:2/GetLastError:203 The parameter is incorrect. Probably the ZIP needs to be saved in a certain format.

Author here. The zip shouldn't need to be saved in any special format. If WinRAR is posing problems then please file an issue because I'd like to fix that. That error doesn't seem like something that would indicate executable corruption. I want to learn more.

I tried to add a file using Windows file explorer, but it just complains "The Compressed (zipped) Folder is invalid or corrupted."

This is on Windows 10 19042 build.

7-Zip doesn't even see the folders for that matter.

Re: Show HN: Redbean – Single-file distributable web server

#85
post #66

Why does the magic numbers list have a XENIX column?

Author here. The name was chosen mostly out of playfulness to describe Windows since I seem to recall XENIX being the earliest example of Microsoft dipping their toes in the water with UNIX support.

Re: Show HN: Redbean – Single-file distributable web server

#86
post #81
post #55

Earlier quoted context omitted.

Author here. That error happens if you have binfmt_misc enabled. The solution is simple: sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" I intend to upstream a patch with the Linux kernel so it can do this automatically. If any kernel devs are reading, please email me!

Does it work on cheap Xen vps? Because "/proc/sys/fs/binfmt_misc/register" looks absent from mine.

That's strange. I'd recommend filing an issue. Any details on how I can reproduce the error will be helpful, even if I have to temporarily rent one of those things. I'm on a mission to make binaries portable.

Re: Show HN: Redbean – Single-file distributable web server

#87
post #42

Am I the only one having issues trying to get this working? The webserver starts just fine, but once I add the index.html with zip as in the example, it stops working. This is on Mac 10.15, CentOS 8 and Ubuntu 18.04 LTS. Centos: [centos@test ~]$ ./redbean.com -vv error: Uncaught SIGSEGV on test.novalocal ./redbean.com EINVAL/err=22/errno:2/GetLastError:0 Linux test.novalocal 4.18.0-240.10.1.el8_3.x86_64 #1 SMP Mon Ja…

IIRC, from vague memories of things flying past, Big Sur won't let a modified binary run once it's been checked by Gatekeeper. Which means the first run gets checked and notarised but when you add the `index.html`, the on-disk binary has changed and Gatekeeper won't allow it to run - I guess it's to prevent malicious code modifications, etc.

Oh wow that's good to know. Maybe you have to do something like `cat foo.com >foo2.com` after you've modified it with the zip tool.

Re: Show HN: Redbean – Single-file distributable web server

#88

Someone please be kind and explain to me how this works? Don't different executable formats need different headers? Don't ELF need "0x7F ELF" header? Don't Windows executable need "MZ" header? How is it fulfilling both requirements simultaneously?

The OP explains https://justine.lol/ape.html

Re: Show HN: Redbean – Single-file distributable web server

#89
post #11

Caddy is a single file web server as well :) https://caddyserver.com/ Admittedly they solve different usecases, where Redbean seems to want to serve a whole static site as a single file, which isn't currently possible with Caddy, (but you can run `caddy file-server` to serve the current directory as a static site), but it may become possible in the future with Golang's new embed package https://golang.org/pkg/embed/

That's actually a pretty interesting idea. I wonder if we could make a lite version of Caddy bundled with your website embedded...no need to mess with file systems or permissions or devices and folders to run a static site. Might need some massaging to become a truly pleasant workflow though.

The go std library offers the embed package. You can just embed your files and use the std lib's webserver and generate a single file binary. No need for Caddy.

All this would be roughly 15 lines of code.

Re: Show HN: Redbean – Single-file distributable web server

#90
post #22
post #13

Earlier quoted context omitted.

Author here. Absolutely. I used to love Turbo Pascal and Delphi when I was younger. If Free Pascal uses GNU LD.BFD or LLVM LLD when it links programs, then all you'd need to do is is configure it to use cosmopolitan.a when linking system call functions like read(), write(), etc. See https://github.com/jart/cosmopolitan Another option is if Free Pascal wants to write all the system call support from scratch, then doin…

I think the Zig community/BDFL might appreciate adding an APE target "os" to their buildchain (LLVM-based); that could be a match made in heaven!

Author here. I've been chatting with the Zig BDFL on Twitter recently about contributing APE support and he's been super supportive so far. It's going to be a nontrivial undertaking but would certainly be rewarding for everyone if we can make it happen.
Post reply on HN