From 494dedf17035c1699c35cd2559f15a64eaa7eff3 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sun, 1 Nov 2020 20:01:35 +0200 Subject: Initial commit --- .gitignore | 2 ++ client.py | 27 +++++++++++++++++++++++++++ requirements.txt | 3 +++ templates/fastapi.rst | 15 +++++++++++++++ templates/nginx.rst | 24 ++++++++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100755 client.py create mode 100644 requirements.txt create mode 100644 templates/fastapi.rst create mode 100644 templates/nginx.rst diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cd1283 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +nginx.conf +__pycache__ 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])) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ed56b80 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +requests +fastapi +uvicorn diff --git a/templates/fastapi.rst b/templates/fastapi.rst new file mode 100644 index 0000000..8d80f55 --- /dev/null +++ b/templates/fastapi.rst @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import subprocess + +import fastapi + +app = fastapi.FastAPI() + + +def main(): + args = ["uvicorn", "main:app", "--reload"] + subprocess.call(args) + +if __name__ == '__main__': + main() diff --git a/templates/nginx.rst b/templates/nginx.rst new file mode 100644 index 0000000..1fd314d --- /dev/null +++ b/templates/nginx.rst @@ -0,0 +1,24 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + server { + listen 8080; + server_name localhost; + + location / { + root html; + index index.html index.htm; + } + } +} -- cgit v1.2.3