No project description provided
Project description
Flaskerk
Provide OpenAPI document and validation for flask service.
Mainly built for Machine Learning Model services.
Features
- JSON data(request&response) validation with pydantic
- Redoc UI
- OpenAPI spec
- Swagger UI
- support flask url path validation
Quick Start
install with pip install flaskerk
(Python 3.6+)
from typing import List
from flask import Flask, request
from flaskerk import Flaskerk
from pydantic import BaseModel
class Query(BaseModel):
name: str
uid: str
limit: int = 5
class Response(BaseModel):
users: List[str]
app = Flask(__name__)
api = Flaskerk(app)
@app.route('/api/recommend', methods=['POST'])
@api.validate(query=Query, resp=Response)
def recommend():
# algorithm here
user = request.query
print(user.name, user.uid)
return Response(users=['xxx'] * user.limit)
if __name__ == '__main__':
app.run()
try it with http POST :5000/api/recommend name='hello' uid='uuuuu'
or curl -X POST -H "Content-Type: application/json" -d '{"name"="hello", "uid"="uuuuu"}' http://127.0.0.1:5000/api/recommend
Open the docs in http://127.0.0.1:5000/docs .
For more examples, check examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flaskerk-0.2.0.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file flaskerk-0.2.0.tar.gz
.
File metadata
- Download URL: flaskerk-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ea1658ea88feec0eb5f0a12ff276ea2461377860938cfaf939d4f5a9ff5e7e4 |
|
MD5 | 972310872d35b81935e3c3f6f1122514 |
|
BLAKE2b-256 | 93daf0be66d3938d7d92c17aa55f1a38a52937c864ffa658b1d1ab796d0a7192 |
File details
Details for the file flaskerk-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: flaskerk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db23d5017c3c2086ae6a45b921e145b0a552d0943d80c64f1df325f37403ee70 |
|
MD5 | 0685d6e470eca3c5b3d94ac5c1118807 |
|
BLAKE2b-256 | 33cab2254e9251e92d06f05abaa2be6f188d38e1841d262179cb4eced9344120 |