Skip to main content

🍾 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

Metadata

Release files for flask-was 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-was 0.1.0
File Size Uploaded
flask_was-0.1.0.tar.gz 4.8 kB Details

Release files / flask_was-0.1.0.tar.gz

Download URL flask_was-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
704e8bd9f77806f6b8884e5dedcdc68ea856d0fe67a15ecd58b2c28f811a60d1
BLAKE2b-256 checksum
How to use checksums
de1d386bdf6799cbed553b40ccf90eeb114b96dce2f5fc061af53135f2462c59
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page