Skip to content
Snippets Groups Projects
Unverified Commit 064fcab9 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

v0.4 added Vagrant for local debugging

parent c3a527c0
No related branches found
No related tags found
No related merge requests found
Pipeline #62426 failed with stages
in 1 minute and 4 seconds
......@@ -16,7 +16,7 @@ Vagrant.configure("2") do |config|
# Python
apt-get install -y htop curl python3-pip build-essential python3 python3-setuptools
sudo pip3 install --upgrade pip setuptools
sudo pip3 install --upgrade pip setuptools Cython
# Install deps
sudo pip3 install -r /vagrant/requirements.txt
......
......@@ -10,13 +10,16 @@ except ImportError:
from flask_json import FlaskJSONRequest as JsonRequest
MINIJSON_MIME = ('application/minijson', 'application/x-minijson')
class MiniJSONRequest(JsonRequest):
def get_json(self, force=False, silent=False, cache=True):
"""
Return JSON data, if content type is application/minijson it will be loaded
via minijson, else it will be loaded the normal way.
"""
if self.headers.get('Content-Type') == 'application/minijson':
if self.headers.get('Content-Type') in MINIJSON_MIME:
return minijson.loads(self.get_data())
else:
return super().get_json(force, silent, cache)
......
# coding: utf-8
[metadata]
version = 0.3
version = 0.4
name = flask-minijson
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
......
......@@ -11,6 +11,8 @@ class TestMiniJSON(unittest.TestCase):
def test_minijson(self):
data = minijson.dumps({'1': '2'})
resp = self.client.post('/v1', data=data, headers={'Content-Type': 'application/x-minijson'})
self.assertEqual(resp.get_json(), {'status': 'ok'})
resp = self.client.post('/v1', data=data, headers={'Content-Type': 'application/minijson'})
self.assertEqual(resp.get_json(), {'status': 'ok'})
resp = self.client.post('/v1', json={'1': '3'})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment