numberly / flask-stupe Goto Github PK
View Code? Open in Web Editor NEW:syringe: a.k.a. « Flask on steroids »
Home Page: https://flask-stupe.readthedocs.io
License: MIT License
:syringe: a.k.a. « Flask on steroids »
Home Page: https://flask-stupe.readthedocs.io
License: MIT License
Trying to run our README's example without PyMongo installed throws:
Traceback (most recent call last):
File "run.py", line 2, in <module>
from flask_stupe import paginate, schema_required
ImportError: cannot import name 'paginate'
This error is completely normal, because we only expose things that are usable based on the different modules available. But it's not very developer-friendly and an error message explaining that paginate
is not available because pymongo
isn't installed would be much better.
See pallets/flask#3111. Some changes should be made here, starting with the README example, which is no longer up to date.
Using our @paginate
decorator 😏
As we can see here: http://flask.pocoo.org/docs/0.12/api/
Today flask prettify the json output unless:
This function’s response will be pretty printed if it was not requested with X-Requested-With: XMLHttpRequest to simplify debugging unless the JSONIFY_PRETTYPRINT_REGULAR config parameter is set to false. Compressed (not pretty) formatting currently means no indents and no spaces after separators.
We don't want to pass that http header each time!
When doing pagination it is nice to have http headers see https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#pagination and https://tools.ietf.org/html/rfc5988#page-6
These make life much easier than having to roll things yourself which can lead to mistakes
I ran the example in README.md and caught this error while POST-ing data to /user
endpoint with the payload:
{
"username": "itsjef",
"password": "itsme"
}
It was this line: https://github.com/numberly/flask-stupe/blob/master/flask_stupe/validation.py#L19 that caused the bug, since schema.load()
was an instance method.
My workaround is to replace
@schema_required(UserSchema)
with
@schema_required(UserSchema())
Additional Info:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.