aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2020-11-01 20:01:35 +0200
committerFilipp Lepalaan <filipp@mac.com>2020-11-01 20:01:35 +0200
commit494dedf17035c1699c35cd2559f15a64eaa7eff3 (patch)
tree376e1736e696074e6ddb0cde7d9c4345b895da25
downloadhello-494dedf17035c1699c35cd2559f15a64eaa7eff3.tar.gz
hello-494dedf17035c1699c35cd2559f15a64eaa7eff3.tar.bz2
hello-494dedf17035c1699c35cd2559f15a64eaa7eff3.zip
Initial commit
-rw-r--r--.gitignore2
-rwxr-xr-xclient.py27
-rw-r--r--requirements.txt3
-rw-r--r--templates/fastapi.rst15
-rw-r--r--templates/nginx.rst24
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;
+ }
+ }
+}