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.