🍾 Flask extension for JSON API
Project description
🍾 Flask extension for JSON API
This project is created and maintained by ISCLUB studio. Use the MIT license on GITHUB and PYPI
Introduction
Flask-was can better realize the separation of front and back ends. Quickly create data verification and check before the view function runs, generate data and return. You can also create user verification functions to data verification. Fast and elegant
Install
Use pip to install or update:
$ pip install -U flask-was
Example
A simple Signin
from flask import Flask
from flask_was import Was, Checker, Column
app = Flask(__name__)
api = Was(app)
api.addChecker(
namespace="signin",
obj=Checker(
{
"name": Column(api.String, biggest_str=20, smallest_str=4),
"email": Column(api.EmailAddress, biggest_str=255, smallest_str=3),
"password": Column(api.String, biggest_str=20, smallest_str=4),
}
),
)
@app.route("/api/signin", methods=["POST"])
@api.checkeout("signin")
def api_signin(postdata):
if postdata[0]:
print("======== A new user coming ... ========")
print("Name: " + postdata[1]["name"])
print("Email: " + postdata[1]["email"])
return api.send(json={"messagess": "Signin was OK"}, status=200)
else:
return api.send(
json={"messagess": "Have some error. Check you forms", "postdata": postdata},
status=400,
)
app.run()
Post Request:
import requests
print(requests.post(
"http://127.0.0.1:5000/api/signin",
data={
"name":"Flask",
"email":"flask@example.org",
"password":"12345"
},
).text)
Documentation
Read the documentation to get started. The documentation is in the /docs
folder. If this project is helpful to you, please click the Star
Contribution Guide
If you find errors or have good suggestions, please refer to the following template to create issues and pull requests
Good ideas
## Introduction
What can this idea do ...
## Code
The files I changed and what did I do ...
## Info
Version Information...
Python: 3.6.x
Flask: 1.1.x
Flask-Was: 0.1.x
Problems in use
## Buiness
My business needs ...
## Code
Part of the code and full traceback ...
What does my code do ...
## Info
Version Information...
Python: 3.6.x
Flask: 1.1.x
Flask-Was: 0.1.x
If you make a useful contribution, you will be added to the contributors.md
License
MIT LICENSE
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
File details
Details for the file flask_was-0.1.0.tar.gz
.
File metadata
- Download URL: flask_was-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 704e8bd9f77806f6b8884e5dedcdc68ea856d0fe67a15ecd58b2c28f811a60d1 |
|
MD5 | eb84935ceed7b630d7006415f11cc82f |
|
BLAKE2b-256 | de1d386bdf6799cbed553b40ccf90eeb114b96dce2f5fc061af53135f2462c59 |