Yoooo, it's actually that easy? This is the shortest HTTP server config I've ever had to type, unless you count `python3 -m http.server` or something. That's insane.
Yoooo, it's actually that easy? This is the shortest HTTP server config I've ever had to type, unless you count `python3 -m http.server` or something. That's insane.
@spacehobo Okay, the response type isn't the most critical thing, but the important bit is what I have to figure out how to express in httpd.conf next: being able to request any page on my website with the `Accept: text/markdown` HTTP header, and get the original markdown source used to generate the page.
This is fun in its own right, and I use it on the regular from the command line, but it's also something that an extremely silly program I made awhile back depends on. `glu` fetches a page, finds all the blocks of source code in that page, creates a temporary directory, and populates it with those source files, running a command in the directory which defaults to `bash`. For trustworthy websites, it's a quick and dirty "here's the files, try it for yourself" tool. It's currently just smart enough to understand Markdown code blocks that have language tags, like
```python
# hello.py
print("Hello world!")
```
We need the comments to discern the filename, so we need the language to discern comment syntax.
@spacehobo Right? You can even see a demo on my homepage.
Technically, it _prefers_ to deliver markdown, which is why those example commands work with no `-H` headers. It delivers HTML if there's an Accept header AND the header contains "text/html" in there somewhere, which every single graphical browser sends (usually as part of a very expansive list of options).
All my site pages are written in Markdown with some amount of frontmatter at the top. That frontmatter can optionally contain a list of `glu` commands. If, and only if, that option is present, do I render out a widget at the top of the page, where people can conveniently copy an appropriate `glu` command to their clipboard. Notice that the homepage has exactly one: `bash hello.sh`, which references a snippet of shell code in the middle of the document.
@spacehobo Right? It's not some practical important thing, but it's fun.
I actually made this on-stream as an exercise for learning Rust, back when I was streaming on Twitch during my last gap in employment. In fact, I made my website as a rocket.rs app, though I eventually later converted it to be a static site generator. I learned a lot of practical things during those sessions, but ultimately the most practical was "I strongly prefer not to program in Rust."
Very little of my stream content is preserved, and mostly on YouTube, but I'm slowly migrating it to MakerTube, where my reuploads are kinda woven in between new content. I don't stream anymore, but I make short silly things, and also recently an hour-long video of how I downloaded and starting hosting all of English Wikipedia locally on my laptop as a form of civil protest.
Even easier for those who have learned the modern BSD ftp command. (-:
The BSDs decided that since the tool for fetching files was named ftp, they'd just augment the protocols that it was capable of speaking.
#FreeBSD has an extra fetch command as well. But all of them β #NetBSD, #OpenBSD, and the derivatives of those three β have ftp commands that speak HTTP, originating in a lukemftp (later tnftp) project by Luke Mewburn for NetBSD in the 1990s.
It's also in #Debian.
@MaddieM4 I use the python http.server all the time for stuff, itβs so convenient and simple. Python docs claim it has security considerations, but they are not issues for me. Also while looking to see if their security warning was still there just now, I notice that Python 3.14 added TLS support to http.server, which is one of the reasons I usually put these behind nginx to terminate TLS.
https://docs.python.org/3/library/http.server.html#http-server-security