Join 54,926 users and earn money for participation

Minimal Web Applications and the Curl Command

1 3267 boost
Avatar for Polydot
Written by   14
1 year ago

The modern web has changed vastly since it's original incarnation and release in 1991. For the most part, the days of simple webpages with only text, hyperlinks, and a bit of styling are over, while the era of large, interactive, and often invasive webapps has arrived in full force.

Thankfully all the simplistic whimsicality that comes with the early days of the web haven't gone away completely. In fact a new incarnation seems to have come about in the form of what I'm calling curlable webapps or capps for short. Now, what exactly is a curlable webapp? Well, in short capps are no more than using the cURL command on a target URL which serves content intended to be displayed in a terminal.

Capps are probably best understood with an example, so go ahead and open up a terminal, and run the following command -- you can also visit wttr.in in any web browser, graphical or otherwise. If you are using Microsoft Windows then cURL might need to be installed or ran through a Linux virtual machine.

$ curl wttr.in

Voilà, right inside of your terminal you have access to an ASCII art weather report based on your current geolocation, all without running anything more than the curl command. Pretty neat huh? Well, it gets better, when using cURL on wttr.in with a specific URL paths we can gets lots of different information. As seen in the examples below, I am able to check the weather in London, the phase of the moon, and even wttr.in's help page.

$ curl wttr.in/London

$ curl wttr.in/Moon

$ curl wttr.in/:help

Many more amazing capps exist, some are quite useful, some are quite useless. Lets take a look at a handful of them that fall into the useful category, and maybe at the end we will have a look at a few that are more for amusement than anything else.

Cheat Sheets

Remembering every command-line tool as well as all of its associated options is quite the daunting task, even the best of the best will undoubtedly forget tidbits here and there. While a manual command called man exits on most Linux distributions, it doesn't always provide great examples. You could also google for answers, but that isn't quite as fast since you have to open up a browser. This is where cheat.sh comes in handy, combine it with curl and you have an accessible cheat sheet right in your command-line whenever one is needed.

$ curl cheat.sh/ls

$ curl cheat.sh/tar

$ curl cheat.sh/vim

$ curl cheat.sh/:help

QR Codes

One of my favorite capps is this nifty little QR code generator, found at qrenco.de. Qrenco.de takes any input and generates a QR code from it.

$ curl qrenco.de/how

$ curl qrenco.de/amazing

The above commands will generate unique QR codes from the path of "how" and another QR code from the path "amazing". As far as I'm aware qrenco.de doesn't provide the ability to change the size of a QR code, which is unfortunate, but no deal breaker. You can also curl qrenco.de without any parameters to get it's help page.

Dictionary

Something I find myself doing frequently is looking up definitions for words. Being able to use cURL and get a dictionary definition without installing a dictionary application, or opening a web browser is quite a time saver. Here is how it works.

$ curl dict://dict.org/d:internet

$ curl dict://dict.org/d:website

I used cURL to get the definition for the words "internet" and "website", from dict.org. You might notice something funny about the syntax in relation to our previous examples, particularly the "dict://" protocol is specified. As it turns out cURL does more than just use the hypertext (HTTP and HTTPS) protocols, in the example above we are using the dictionary (DICT) protocol.

While you can specify a protocol it generally won't be required, for example the same dict.org commands work with no "dict://" protocol specification.

$ curl dict.org/d:internet

$ curl dict.org/d:website

Also, a note of convenience, a lot of cURL commands can be aliased in your shell to make using them more like normal command-line applications. For example in my '.bashrc' file I have an alias for the dictionary capp used in the above examples.

alias dict="curl dict://dict.org/d:$1"

With this set I can run the previous dictionary searches for "internet" and "website" like so.

$ dict internet

$ dict website

Now our command is much easier to use and remember, as an added bonus it also functions like other command-line applications. For more on aliases checkout my article on command-line efficiency (I'll update this when it is published).

Cryptocurrency Prices

Anyone familiar with cryptocurrency knows the feeling of constantly wanting to check prices. A few capps have this urge covered, the best of the lot being rate.sx, which not only shows a general top 10 chart, but allows for specifying coins.

$ curl rate.sx

$ curl rate.sx/btc

$ curl rate.sx/eth

Another option is cmc.rjldev.com. Unfortunately it is lacking in features -- at least as far as I am aware -- such as not having any special option for filtering currencies. In the example below I pipe the large output of the curl command into less -r this is done to let you start at the top of the chart: the less command is often useful when combined with capps.

$ curl cmc.rjldev.com | less -r

Shorten URL

You could install an application to shorten your URLs or maybe use some website filled with slow Javascript, but why do that when you can just use cURL.

$ curl -F'shorten=https://youtube.com' https://0x0.st

$ curl -F'shorten=https://google.com' https://0x0.st

When you run the above commands they will make a shortened URL for accessing youtube.com and google.com respectively. Like the example I provided in the dictionary section, this capp is much better when set to a shell alias. When aliased to "shorturl" the examples below would perform the same function of shortening URLs as the above examples, but with a more compact and rememberable syntax.

$ shorturl https://youtube.com

$ shorturl https://google.com

News

A personal favorite example of the possibilities with capps is getnews.tech. While it isn't as flashy as some of the other apps, it is an example of quite an important web use case.

$ curl getnews.tech

$ curl getnews.tech/trump

$ curl getnews.tech/world+cup

$ curl getnews.tech/trump | less -r

Essentially, getnews.tech provides related articles to words provided in the URLs path. An additional feature that would make getnews.tech more useful is the addition of opening specific articles after doing general searches.

Less Practical Capps

Lets look at a few more capps that are less practical, but still neat.

Parrot.live is a demonstration of animation, which hasn't been seen in any of the previously listed capps.

$ curl parrot.live

Whatthecommit.com is supposed to be used when doing a git commit, as it picks the commit message for you. It shouldn't need to be said -- though I'll say it anyway -- using these commit messages is a terrible idea, especially in important projects.

$ curl -sk https://whatthecommit.com/index.txt

$ git commit -m $(curl -sk https://whatthecommit.com/index.txt)

Ping.gg has some practical use cases, the only problem is most of the time you can use pre-installed commands to do exact same thing that ping.gg accomplishes. It just doesn't seem worth going through a third party (ping.gg), nevertheless checkout the examples below.

$ curl ping.gg

$ curl ping.gg/me@example.org/104.28.13.51

Summary

Capps will never be a drop in replacement for the modern web, but they do offer many benefits, the foremost being speed. For command-line aficionados capps might actually be a great way to access some basic content like the weather, crypto prices, et cetera.

The current state of capps is more akin to some neat party tricks to show your friends, but it obviously doesn't have to be that way. The ecosystem for capps is still infantile, but the potential is quite obvious at this point, we just need creative ideas, and powerful implementations. With that said, now we wait, or create.

1
$ 2.60
$ 2.00 from @Read.Cash
$ 0.50 from @SpokenWords
$ 0.10 from @Devalbo
Avatar for Polydot
Written by   14
1 year ago
Enjoyed this article?  Earn Bitcoin Cash by sharing it! Explain
...and you will also help the author collect more tips.

Comments

90's was BBS time, haha

$ 0.00
1 year ago