diff options
author | Filipp Lepalaan <filipp@mac.com> | 2020-11-01 20:01:35 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2020-11-01 20:01:35 +0200 |
commit | 494dedf17035c1699c35cd2559f15a64eaa7eff3 (patch) | |
tree | 376e1736e696074e6ddb0cde7d9c4345b895da25 /client.py | |
download | hello-494dedf17035c1699c35cd2559f15a64eaa7eff3.tar.gz hello-494dedf17035c1699c35cd2559f15a64eaa7eff3.tar.bz2 hello-494dedf17035c1699c35cd2559f15a64eaa7eff3.zip |
Initial commit
Diffstat (limited to 'client.py')
-rwxr-xr-x | client.py | 27 |
1 files changed, 27 insertions, 0 deletions
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])) |