From a97f3738b24f0125d2aef19fe4421a6730398692 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Fri, 27 Oct 2023 11:37:07 +0100 Subject: [PATCH] starting to add pwgen --- pw_generaturr/pw_generaturr.nimble | 13 +++++++++++++ pw_generaturr/src/pw_generaturr.nim | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pw_generaturr/pw_generaturr.nimble create mode 100644 pw_generaturr/src/pw_generaturr.nim diff --git a/pw_generaturr/pw_generaturr.nimble b/pw_generaturr/pw_generaturr.nimble new file mode 100644 index 0000000..9fd4a3c --- /dev/null +++ b/pw_generaturr/pw_generaturr.nimble @@ -0,0 +1,13 @@ +# Package + +version = "0.1.0" +author = "Paul Wilde" +description = "A new awesome nimble package" +license = "AGPL-3.0-or-later" +srcDir = "src" +bin = @["pw_generaturr"] + + +# Dependencies + +requires "nim >= 2.0.0" diff --git a/pw_generaturr/src/pw_generaturr.nim b/pw_generaturr/src/pw_generaturr.nim new file mode 100644 index 0000000..41f95f3 --- /dev/null +++ b/pw_generaturr/src/pw_generaturr.nim @@ -0,0 +1,17 @@ +import ../../globurrl + +import httpclient +import json + +proc getPW() = + var c = newHttpClient() + try: + let resp = c.get("https://random-word-api.herokuapp.com/word?length=5") + if resp.status == $Http200: + echo resp.body.parseJson + + except: + echo getCurrentExceptionMsg() + +if isMainModule: + getPW()