Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flask_minijson
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
flask_minijson
Commits
064fcab9
Unverified
Commit
064fcab9
authored
1 year ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
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
Stage: build
Stage: test
in 1 minute and 4 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Vagrantfile
+1
-1
1 addition, 1 deletion
Vagrantfile
flask_minijson.py
+4
-1
4 additions, 1 deletion
flask_minijson.py
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
tests/test_minijson.py
+2
-0
2 additions, 0 deletions
tests/test_minijson.py
with
8 additions
and
3 deletions
Vagrantfile
+
1
−
1
View file @
064fcab9
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
flask_minijson.py
+
4
−
1
View file @
064fcab9
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
setup.cfg
+
1
−
1
View file @
064fcab9
# 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
...
...
This diff is collapsed.
Click to expand it.
tests/test_minijson.py
+
2
−
0
View file @
064fcab9
...
...
@@ -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
'
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment