Skip to main content

package flask to use conveniently like django

Project description

Flask Api Resource

package flask to use conveniently like django

Usage

Step 1

from flask import Flask
from flask_api_resource import FlaskApiResource

app = Flask(__name__)
app.config['INSTALL_APPS'] = []  # your application app like user
api = FlaskApiResource()
api.init_app(app=app)  # this can auto scan your resource

Step 2

According to your logic to create different app

user
    __init__.py
    apis
        user.py
# user.py
from flask_api_resource.api import BaseResource
from flask_api_resource.decorator import get

class UserResource(BaseResource):
    
    def get_urls(self):
        return [
            ('/detail', self.detail)
        ]
    
    @get
    def detail(self):
        return self.success({'id': 1})
# __init__.py

def register(api):
    from .apis.user import UserResource
    api.register(UserResource)

Step 3

run the Flask app server and open the http://127.0.0.1:5000/rest/user/detail

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-api-resource, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size flask-api-resource-0.1.2.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page