ASCII art as a service

node v8.9.3
version: 3.0.0
endpointsharetweet
await asciiArt("ascii art", "3D-ASCII") .then(art_obj => art_obj["ascii_art"])
await asciiArt("AS A SERVICE", "Standard") .then(art_obj => art_obj["ascii_art"])
/* +---------------+ | What? | +---------------+ */
I developed an API for ASCII art. This is an interactive notebook in which we'll take it for a spin --
Querying "https://asciiart-fdljfuzfva.now.sh/api/fonts" for the available fonts we can use --
await availableFonts();
Querying "https://asciiart-fdljfuzfva.now.sh/api/metadata/<font_name>" to retrieve a font's default options and header comment --
await metadata("Standard")
Querying "https://asciiart-fdljfuzfva.now.sh/api/text/<text>/font/<font_name>/hlayout/<horizontal_layout>/vlayout/<vertical_layout>" to retrieve ASCII art for text(expand the output cell to see the ASCII art) --
await asciiArt("ASCII ART", "Small Isometric1")
You can browse through all the available fonts here(expand the output cells to see the ASCII art) --
async function demoAllFonts() { var fonts_obj = await availableFonts(); for (font of fonts_obj["fonts"]) { var art_obj = await asciiArt("art", font); console.log(font + "\n----\n" + art_obj["ascii_art"]) } } await demoAllFonts()
API wrapper --
async function availableFonts() { return JSON.parse(await require("request-promise")("https://asciiart-fdljfuzfva.now.sh/api/fonts")); }; async function metadata(font_name) { return JSON.parse(await require("request-promise")("https://asciiart-fdljfuzfva.now.sh/api/metadata/" + font_name)); }; async function asciiArt(text, font_name = "Standard", horizontal_layout = "default", vertical_layout = "default") { return JSON.parse(await require("request-promise")("https://asciiart-fdljfuzfva.now.sh/api/text/" + text + "/font/" + font_name + "/hlayout/" + horizontal_layout + "/vlayout/" + vertical_layout)); };
module.exports = { availableFonts: availableFonts, metadata: metadata, asciiArt: asciiArt, };
/* +----------------+ | How? | +----------------+ */
Written in JavaScript using the Express web framework(https://expressjs.com/) and figlet(https://www.npmjs.com/package/figlet). Deployed on now(https://zeit.co/now).
Loading…

no comments

    sign in to comment