Flask-REST-Controller
Flask-REST-Controller is added Class-Based-View(Controller) extension on Flask
Features
Follow the RESTful design
provide of prepare authentication and request validation
other class based view library is not provided of validation
uniform routing management
The existing functional view is difficult to manage. Definition routing Scattered
JSON Response Validation with JSON Schema
It would be useful for creating an API :)
Installation
$ pip install flask-rest-controller
Usage
from flask import Flask
from flask_rest_controller import Controller, set_routing
app = Flask(__name__)
app.secret_key = 'Í| èg<Î|ÇæãhÖúÈi|î°'
class JsonController(Controller):
schema = {
'GET': {
'type': 'array',
'properties': {
'id': {
'type': 'string'
}
}
},
'POST': {
'type': 'object',
'properties': {
'result': {
'type': 'string'
},
'code': {
'type': 'integer'
}
}
}
}
def get(self):
return self.render_json(["Hello World"])
def post(self):
return self.render_json({'result': "ok", 'code': 200})
ROUTING = [
("/", "app.JsonController", "json_controller"),
]
set_routing(app, ROUTING)
if __name__ == "__main__":
app.run(debug=True)
Just save it as app.py and try
$ python app.py
Now head over to http://127.0.0.1:5000/, and you should see your hello world of json string
You should see a post request result, try this command
$ curl --request POST http://127.0.0.1:5000
You should see that you json in the post method
see https://github.com/teitei-tk/Flask-REST-Controller/tree/master/example For other examples
Dependencies
Python2.6 later
jsonschema
Contribute
Fork it
Create your feature branch (git checkout -b your-new-feature)
Commit your changes (git commit -am 'Added some feature')
Push to the branch (git push origin your-new-feature)
Create a new Pull Request
LICENSE
MIT
Metadata
Release files for Flask-REST-Controller 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-REST-Controller-1.0.0.tar.gz | 6.0 kB | Without provenance | Details for Flask-REST-Controller-1.0.0.tar.gz |
Release files / Flask-REST-Controller-1.0.0.tar.gz
| Download URL | Flask-REST-Controller-1.0.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47db8ba9dc8c471ddcaaf71af5608e651bbfd15f70756854d8c314b7d307a705
|
|
BLAKE2b-256 checksum How to use checksums |
76b8268e43806789aaaa42dea9c3555cb48d96cec7d36e1acbaeeaad8b9c16a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-REST-Controller 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.