Browse Source

Upgrade apistar to 0.5.39 (#3866)

Kowit Charoenratchatabhan 7 years ago
parent
commit
a3328f6a98

+ 1 - 1
frameworks/Python/apistar/apistar.dockerfile

@@ -6,4 +6,4 @@ WORKDIR /apistar
 
 RUN pip3 install -r /apistar/requirements.txt
 
-CMD gunicorn app:app.wsgi -c gunicorn_conf.py
+CMD gunicorn app:app -c gunicorn_conf.py

+ 8 - 22
frameworks/Python/apistar/app.py

@@ -1,30 +1,16 @@
-from apistar import App, Route, wsgi
-import ujson as json
+from apistar import App, Route, http
 
 
-def json_view() -> wsgi.WSGIResponse:
-    content = json.dumps({'message': 'Hello, world!'}).encode('utf-8')
-    return wsgi.WSGIResponse(
-        '200 OK',
-        [
-            ('Content-Type', 'application/json'),
-            ('Content-Length', str(len(content)))
-        ],
-        [content]
-    )
+def json_view() -> http.JSONResponse:
+    content = {'message': 'Hello, world!'}
+    return http.JSONResponse(content, status_code=200)
 
 
-def plaintext_view() -> wsgi.WSGIResponse:
-    content = b'Hello, world!'
-    return wsgi.WSGIResponse(
-        '200 OK',
-        [
-            ('Content-Type', 'text/plain'),
-            ('Content-Length', str(len(content)))
-        ],
-        [content]
-    )
+def plaintext_view() -> http.Response:
 
+    content = 'Hello, world!'
+    headers = {'Content-Type': 'text/plain'}
+    return http.Response(content, headers=headers)
 
 app = App(routes=[
     Route('/json', 'GET', json_view),

+ 2 - 2
frameworks/Python/apistar/requirements.txt

@@ -1,4 +1,4 @@
-gunicorn==19.7.1
+gunicorn==19.8.1
 meinheld==0.6.1
-apistar==0.1.6
+apistar==0.5.39
 ujson==1.35