From 494dedf17035c1699c35cd2559f15a64eaa7eff3 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sun, 1 Nov 2020 20:01:35 +0200 Subject: Initial commit --- client.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 client.py (limited to 'client.py') diff --git a/client.py b/client.py new file mode 100755 index 0000000..28b9c45 --- /dev/null +++ b/client.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import os +import sys +import requests + +def main(arg=None): + repo = os.getenv("HELLO_REPO") + assert repo is not None, "No repo configured!" + + templates = [] + for t in requests.get(repo).json(): + templates.append(t['name']) + + if arg is None: + return templates + + if arg in templates: + url = "{0}/{1}".format(repo.rstrip("/"), arg) + template = requests.get(url).text + return template + else: + error = "Template for {0} not found".format(arg) + raise Exception(error) + + +if __name__ == '__main__': + print(main(sys.argv[1])) -- cgit v1.2.3