Ver Fonte

Adds hug framework with uwsgi configuration to tfb project (#4307)

* Adds hug framework with uwsgi configuration to tfb project

* remove gunicorn from the config
Julian Coleman há 6 anos atrás
pai
commit
b0fc360856

+ 0 - 0
frameworks/Python/hug/README.md


+ 29 - 0
frameworks/Python/hug/app.py

@@ -0,0 +1,29 @@
+import hug
+
+from datetime import datetime
+
+
+# Create decorators for mimetypes (JSON is default)
+plaintext = hug.get(output=hug.output_format.text)
+json      = hug.get(output=hug.output_format.json)
+
+
+# Create a directive to add necessary headers
[email protected]_middleware()
+def set_required_headers(request, response, resource):
+    date_obj      = datetime.now()
+    rfc_1123      = "%a, %d %b %Y %H:%M:%S GMT"
+    rfc_1123_date = date_obj.strftime(rfc_1123)
+
+    headers       = { "Server": "hug", "Date": rfc_1123_date }
+
+    response.set_headers(headers)
+
+
+@plaintext
[email protected]("/plaintext")
+def plaintext():
+    """Plaintext handler."""
+    return "Hello, World!"
+
+app = hug.API(__name__).http.server()

+ 25 - 0
frameworks/Python/hug/benchmark_config.json

@@ -0,0 +1,25 @@
+{
+  "framework": "hug",
+  "tests": [
+    {
+      "uwsgi": {
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "Hug",
+        "language": "Python",
+        "flavor": "Python3",
+        "orm": "Raw",
+        "platform": "Falcon",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Hug",
+        "notes": "CPython 2",
+        "versus": "wsgi"
+      }
+    }
+  ]
+}

+ 10 - 0
frameworks/Python/hug/hug-uwsgi.dockerfile

@@ -0,0 +1,10 @@
+FROM python:3.6.6-stretch
+
+WORKDIR /hug
+COPY app.py app.py
+COPY uwsgi.ini uwsgi.ini
+COPY requirements.txt requirements.txt
+
+RUN pip3 install -r requirements.txt
+
+CMD ["uwsgi", "--ini", "uwsgi.ini"]

+ 6 - 0
frameworks/Python/hug/requirements.txt

@@ -0,0 +1,6 @@
+Cython==0.28.5
+hug==2.3.2
+uWSGI==2.0.17.1
+greenlet==0.4.14
+gunicorn==19.9.0
+meinheld==0.6.1

+ 13 - 0
frameworks/Python/hug/uwsgi.ini

@@ -0,0 +1,13 @@
+; These preferences specifically tuned for performance.
+
+[uwsgi]
+http=:8080
+chdir=/hug
+wsgi-file=/hug/app.py
+callable=app
+workers=%(%k * 2 + 1)
+processes=%k
+enable-threads=True
+threads=1
+disable-logging=True
+max-worker-lifetime=30