diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | client.py | 27 | ||||
-rw-r--r-- | requirements.txt | 3 | ||||
-rw-r--r-- | templates/fastapi.rst | 15 | ||||
-rw-r--r-- | templates/nginx.rst | 24 |
5 files changed, 71 insertions, 0 deletions
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; + } + } +} |