当前位置: 首页>>代码示例>>Python>>正文


Python rest.RestAPI类代码示例

本文整理汇总了Python中flask_peewee.rest.RestAPI的典型用法代码示例。如果您正苦于以下问题:Python RestAPI类的具体用法?Python RestAPI怎么用?Python RestAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RestAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialize

def initialize():
    global db, api

    db = Database(app)

    # Setup models
    import models
    models.setup()

    # Register REST api
    api = RestAPI(app)
    api.register(models.Flow)
    api.setup()
开发者ID:codito,项目名称:flow,代码行数:13,代码来源:flow.py

示例2: setup_api

def setup_api(auth):
    user_auth = UserAuthentication(auth)
    api = RestAPI(app, default_auth=user_auth)
    api.register(Note)
    api.register(Author)
    api.setup()
    return api
开发者ID:fspot,项目名称:flask-peewee-example,代码行数:7,代码来源:rest.py

示例3: UserAuthentication

from flask_peewee.rest import RestAPI, UserAuthentication

from app import app
from auth import auth
from models import Note

user_auth = UserAuthentication(auth)
api = RestAPI(app, default_auth=user_auth)
api.register(Note)
api.setup()
开发者ID:datashaman,项目名称:flask-peewee,代码行数:10,代码来源:api.py

示例4: SessionAuthResource

class SessionAuthResource(RestResource):
    def authorize(self):
        return True
        # return session.get('magic', '') == 'a'


class ScriptResource(SessionAuthResource):
    pass


class ReportResource(SessionAuthResource):
    paginate_by = 100

    def get_query(self):
        if request.args.get('method', '') == "listURI":
            # monkey patch fields
            self._fields = {self.model: ['latest', 'count', 'uri']}
            return Report.select(Report.uri, fn.Count(Report.id).alias(
                'count'), fn.Max(Report.created).alias('latest')).group_by(
                Report.uri).order_by(fn.Max(Report.created).desc())
        else:
            self._fields = {self.model: self.model._meta.get_field_names()}
            return SessionAuthResource.get_query(self)


api = RestAPI(app)
api.register(Report, ReportResource)
api.register(Script, ScriptResource)
api.setup()
开发者ID:ccp0101,项目名称:xssreport,代码行数:29,代码来源:api.py

示例5: UserAuthentication

from flask_peewee.rest import RestAPI, UserAuthentication
from psyc import app
#from models.models import Note
import psyc.models.processor as processor
from auth import auth

user_auth = UserAuthentication(auth)
api = RestAPI(app, default_auth=user_auth)
#api.register(processor.Processor, processor.ProcessorResource)
api.setup()
开发者ID:tlodge,项目名称:dataware.experiment,代码行数:10,代码来源:rest.py

示例6: UserAuthentication

from flask_peewee.rest import RestAPI, RestResource, UserAuthentication, AdminAuthentication, RestrictOwnerResource

from app import app
from auth import auth
from models import User, Message, Relationship, City, Pinche


user_auth = UserAuthentication(auth)
admin_auth = AdminAuthentication(auth)

# instantiate our api wrapper
api = RestAPI(app, default_auth=user_auth)

class UserResource(RestResource):
    exclude = ('password', 'email',)

class MessageResource(RestrictOwnerResource):
    owner_field = 'user'
    include_resources = {'user': UserResource}

class RelationshipResource(RestrictOwnerResource):
    owner_field = 'from_user'
    include_resources = {
        'from_user': UserResource,
        'to_user': UserResource,
    }
    paginate_by = None

class CityResource(RestResource):
    exclude = ()
开发者ID:jade-bot,项目名称:pinche,代码行数:30,代码来源:api.py

示例7: RestAPI

from flask_peewee.rest import RestAPI, RestResource, UserAuthentication, AdminAuthentication, RestrictOwnerResource

from app import app
from auth import auth
from models import Councillor, Promise, Decision, Comment

api = RestAPI(app)
admin_auth = AdminAuthentication(auth)

class CantonResource(RestResource):
    exclude = ()

class CouncilResource(RestResource):
    exclude = ()

class PartyResource(RestResource):
    exclude = ()

class CouncillorResource(RestResource):
    include_resources = {
        'canton': CantonResource,
        'council': CouncilResource,
        'party': PartyResource,
    }

class PromiseResource(RestResource):
    include_resources = {
        'councillor': CouncillorResource
    }

class DecisionResource(RestResource):
开发者ID:loleg,项目名称:kandidaten,代码行数:31,代码来源:api.py

示例8: UserResource

admin.register_panel('Notes', NotePanel)


class UserResource(RestResource):
    exclude = ('password', 'email',)
    
    def get_query(self):
        return User.filter(active=True)


# rest api stuff
user_auth = UserAuthentication(auth)
admin_auth = AdminAuthentication(auth)
api_key_auth = APIKeyAuthentication(APIKey, ['GET', 'POST', 'PUT', 'DELETE'])

api = RestAPI(app, default_auth=user_auth)

api.register(Message, RestrictOwnerResource)
api.register(User, UserResource, auth=admin_auth)
api.register(Note)
api.register(TestModel, auth=api_key_auth)


# views
@app.route('/')
def homepage():
    return Response()

@app.route('/private/')
@auth.login_required
def private_timeline():
开发者ID:indirecthit,项目名称:flask-peewee,代码行数:31,代码来源:test_app.py

示例9: UserAuthentication

from flask_peewee.rest import RestAPI, RestResource, UserAuthentication, AdminAuthentication, RestrictOwnerResource

from app import app
from auth import auth
from models import User, Message, Relationship, City, Pinche
from models import CarBrand, CarSeries, CarModel

user_auth = UserAuthentication(auth)
admin_auth = AdminAuthentication(auth)

# instantiate our api wrapper
api = RestAPI(app, default_auth=user_auth)

class UserResource(RestResource):
    exclude = ('password', 'email',)

class MessageResource(RestrictOwnerResource):
    owner_field = 'user'
    include_resources = {'user': UserResource}

class RelationshipResource(RestrictOwnerResource):
    owner_field = 'from_user'
    include_resources = {
        'from_user': UserResource,
        'to_user': UserResource,
    }
    paginate_by = None

class CityResource(RestResource):
    exclude = ()
开发者ID:lite,项目名称:pinche,代码行数:30,代码来源:api.py

示例10: UserAuthentication

from flask_peewee.rest import RestAPI, RestResource, UserAuthentication, AdminAuthentication, RestrictOwnerResource

from app import app
from auth import auth
from models import User, Message#, Relationship


user_auth = UserAuthentication(auth)
admin_auth = AdminAuthentication(auth)

# instantiate our api wrapper
api = RestAPI(app, default_auth=user_auth)


class UserResource(RestResource):
    exclude = ('password', 'email',)


class MessageResource(RestrictOwnerResource):
    owner_field = 'user'
    include_resources = {'user': UserResource}


# register our models so they are exposed via /api/<model>/
api.register(User, UserResource, auth=admin_auth)
api.register(Message, MessageResource)
开发者ID:sekenned,项目名称:totb,代码行数:26,代码来源:api.py

示例11: Authentication

from flask import render_template
from flask_peewee.rest import Authentication
from flask_peewee.rest import RestAPI
from flask_peewee.rest import RestResource

from app import app
from models import Note
from models import Task


# Allow GET and POST requests without requiring authentication.
auth = Authentication(protected_methods=['PUT', 'DELETE'])
api = RestAPI(app, default_auth=auth)

class NoteResource(RestResource):
    fields = ('id', 'content', 'timestamp', 'status')
    paginate_by = 30

    def get_query(self):
        return Note.public()

    def prepare_data(self, obj, data):
        data['rendered'] = render_template('note.html', note=obj)
        return data

class TaskResource(RestResource):
    paginate_by = 50

api.register(Note, NoteResource)
api.register(Task, TaskResource)
开发者ID:tolmun,项目名称:flask-notes,代码行数:30,代码来源:api.py

示例12: Flask

from rui.series.model import Fansub
from rui.series.model import ScrapParam
from rui.series.model import ScrapParamTemplate
from rui.series.model import Notification
from rui.series.model import db

from rui.config import data as dataConfig

from rui.series.resources import NotificationResource

# Define the WSGI application object
app = Flask(__name__)
app.config["DATABASE"] = {"name": dataConfig["path"], "engine": "peewee.SqliteDatabase"}
app.config["SECRET_KEY"] = '?\xbf,\xb4\x8d\xa3"<\x9c\[email protected]\x0f5\xab,w\xee\x8d$0\x13\x8b83'
# instantiate our api wrapper
api = RestAPI(app)

# Admin area


db = Database(app)

# needed for authentication
auth = Auth(app, db)
# auth.User.create_table(fail_silently=True)

demo = auth.User(username="demo", email="", admin=True, active=True)
demo.set_password("sonata")
demo.save()

admin = Admin(app, auth)
开发者ID:twissell-,项目名称:rui,代码行数:31,代码来源:__init__.py

示例13: Flask

from flask import Flask
from flask_peewee.rest import RestAPI

import models

app = Flask(__name__)

# instantiate our api wrapper
api = RestAPI(app)

# register our models so they are exposed via /api/<model>/
api.register(models.Article)

# configure the urls
api.setup()

if __name__ == '__main__':
    app.run(debug=True)

开发者ID:igniteflow,项目名称:the-daily-wtf-reader,代码行数:18,代码来源:app.py

示例14: RestAPI

from flask_peewee.rest import RestAPI, RestResource

from app import app
from customer import Customer
from product import Product

api = RestAPI(app)

api.register(Customer)
api.register(Product)

api.setup()
开发者ID:gitlabuser,项目名称:CMNT_004_15,代码行数:12,代码来源:rest_interface.py

示例15: UserResource

# create a special resource for users that excludes email and password
class UserResource(RestResource):
    exclude = ('password', 'email',)


# class LogrefillResource(RestResource):

#     def prepare_data(self, obj, data):
#         data["credit"] = str(data["credit"])
#         return data


# instantiate the user auth
user_auth = UserAuthentication(auth, protected_methods=['GET', 'POST', 'PUT', 'DELETE'])


# create a RestAPI container
api = RestAPI(app, default_auth=user_auth)
# register the models
api.register(Card, CardResource, auth=user_auth)
api.register(CardGroup, auth=user_auth)
api.register(Callerid, auth=user_auth)
api.register(Logrefill, auth=user_auth)
api.register(Logpayment, auth=user_auth)
api.register(Call, auth=user_auth)
api.register(Country, auth=user_auth)
api.register(Charge, auth=user_auth)
# api.register(Did, auth=user_auth)
# api.register(DidDestination, auth=user_auth)
api.register(auth.User, UserResource, auth=user_auth)
开发者ID:amar266,项目名称:a2billing-flask-api,代码行数:30,代码来源:api.py


注:本文中的flask_peewee.rest.RestAPI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。