Pārlūkot izejas kodu

Python Eve API framework (#4222)

* initial commit of javalin framework with two tests - json and plaintext

* removed unncecessary gradle files and adjusted the dockerfile and build.gradle to add a gradle build step prior to running

* removed commented-out line from dockerfile

* aded javalin to travis.yml file

* initial commit of Golang Iris framework with 5 tests

* fixed readme to add some clarifying terms

* [ci skip] removed gitignore and license

* [ci skip] removed unecessary code from benchmark_config

* placed graphql-express implementations under the express framework

* added eve to tfb with two tests
jenriquez-techempower 6 gadi atpakaļ
vecāks
revīzija
8520b22f32

+ 12 - 0
frameworks/Python/eve/README.md

@@ -0,0 +1,12 @@
+# [Eve](https://github.com/pyeve/eve) Benchmarking Test
+
+This is the Eve portion of a [benchmarking tests suite](../../)
+comparing a variety of web development platforms.
+
+The information below is specific to Eve. For further guidance,
+review the [documentation](http://docs.python-eve.org/en/latest).
+
+## Test Paths & Sources
+
+* [JSON Serialization]: "/json"
+* [Plaintext]: "/plaintext" 

+ 31 - 0
frameworks/Python/eve/app.py

@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+
+from eve import Eve
+from flask import request
+import json
+
+port = 8080
+host = '127.0.0.1'
+
+app = Eve()
+
[email protected]_request
+def add_correct_headers(response):
+    path = request.path
+    if path == '/json':
+        response.headers['Content-Type'] = 'application/json'
+    elif path == '/plaintext':
+        response.headers['Content-Type'] = 'text/plain'
+    return response
+
[email protected]('/plaintext')
+def hello_world():
+    return 'Hello, World!'
+
[email protected]('/json')
+def jsonHello():
+    hello = {'message': 'Hello, World!'}
+    return json.dumps(hello)
+
+if __name__ == '__main__':
+    app.run(host=host, port=port)

+ 24 - 0
frameworks/Python/eve/benchmark_config.json

@@ -0,0 +1,24 @@
+{
+  "framework": "eve",
+  "tests": [{
+    "default": {
+      "plaintext_url" : "/plaintext",
+      "json_url" : "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "None",
+      "framework": "Eve",
+      "language": "Python",
+      "flavor": "Python2",
+      "orm": "Full",
+      "platform": "None",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Eve",
+      "notes": "",
+      "versus": ""
+    }
+  }]
+}

+ 11 - 0
frameworks/Python/eve/eve.dockerfile

@@ -0,0 +1,11 @@
+FROM aleksxp/docker-eve-python:legacy
+
+ADD ./ /eve
+
+WORKDIR /eve
+
+COPY . .
+
+RUN pip install -r requirements.txt
+
+CMD gunicorn app:app -c gunicorn_conf.py

+ 26 - 0
frameworks/Python/eve/gunicorn_conf.py

@@ -0,0 +1,26 @@
+import multiprocessing
+import os
+import sys
+
+_is_pypy = hasattr(sys, 'pypy_version_info')
+_is_travis = os.environ.get('TRAVIS') == 'true'
+
+workers = multiprocessing.cpu_count() * 3
+if _is_travis:
+    workers = 2
+
+bind = "0.0.0.0:8080"
+keepalive = 120
+errorlog = '-'
+pidfile = 'gunicorn.pid'
+
+if _is_pypy:
+    worker_class = "tornado"
+else:
+    worker_class = "meinheld.gmeinheld.MeinheldWorker"
+
+    def post_fork(server, worker):
+        # Disable access log.
+        # (Until https://github.com/mopemope/meinheld/pull/42 is released)
+        import meinheld.server
+        meinheld.server.set_access_logger(None)

+ 8 - 0
frameworks/Python/eve/requirements.txt

@@ -0,0 +1,8 @@
+click==6.7
+Flask==0.12.2
+greenlet==0.4.14
+gunicorn==19.9.0
+itsdangerous==0.24
+meinheld==0.6.1
+uWSGI==2.0.17.1
+Werkzeug==0.14.1

+ 18 - 0
frameworks/Python/eve/settings.py

@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+import os
+
+RESOURCE_METHODS = ['GET']
+
+ITEM_METHODS = ['GET', 'PATCH', 'DELETE']
+
+CACHE_CONTROL = 'max-age=20'
+CACHE_EXPIRES = 20
+
+DOMAIN = {}
+
+RENDERERS = {
+    'eve.render.JSONRenderer'
+}
+
+DEBUG = True