Mastodon Feed: Post

Mastodon Feed

jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:

this is so very simple and readable in D:

import std.stdio;
import std.net.curl;
import std.string;
import std.array;

void main( string[] args ) {
if( args.length < 2 ) {
writeln( "Usage: ./main " );
return;
}

string url = args[1];
try {
auto content = cast( string ) get( url );
writeln( content );
}
catch( Exception e ) {
writeln( "\nHTTP 418: I am a teapot\n" );
}
}