예제 #1
0
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
예제 #2
0
class DataStore():
    def __init__(self):
        # Initialize flask
        self.flask = Flask('data_store')
        self.api = RestAPI(self.flask)

    def register(self, model):
        self.api.register(model)
        # Configure the URLs
        self.api.setup()
def setup(app):
    from . import RestAPI_patch
    rest_api = RestAPI(app, default_auth=Authentication(protected_methods=[]))

    # register user api
    for api in APIRestResource.__subclasses__():
        register_api(rest_api, api)
    api_info(app)

    rest_api.setup()
예제 #4
0
파일: flow.py 프로젝트: codito/flow
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()
예제 #5
0
파일: api_2.py 프로젝트: tigal/mooc
class InitAPI2(InitBaseExtension):

    name = 'api2'

    def init_app(self, app):  # Инициализируем RestAPI от peewee
        self.extension = RestAPI(app.web_app)
        self.extension.default_auth = Authentication(protected_methods=[])

    def configurate_extension(self):

        from models import get_models

        for m in get_models():
            self.extension.register(m)

        self.extension.setup()
예제 #6
0
version='1.00'

start_time = datetime.now()
app = Flask(__name__)
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False


# instantiate our api wrapper
api = RestAPI(app)

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

# configure the urls
api.setup()


@app.route('/')
def test():
    return "flask is running for {} seconds...".format(datetime.now() - start_time)


@app.route('/add', methods=['GET'])
def add_managed_instance():
    name = request.args.get('name')
    private_ns = request.args.get('private_ns')
    public_ns = request.args.get('public_ns')
    public_access = request.args.get('public_access')
    price = request.args.get('price')
    ami = request.args.get('ami')
예제 #7
0
api.register(Message, RestrictOwnerResource)
api.register(User, UserResource, auth=admin_auth)
api.register(Note)
api.register(TestModel, auth=api_key_auth)
api.register(AModel, AResource, auth=dummy_auth)
api.register(BModel, BResource, auth=dummy_auth)
api.register(CModel, CResource, auth=dummy_auth)

api.register(EModel, EResource, auth=dummy_auth)
api.register(FModel, FResource, auth=dummy_auth)


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

@app.route('/private/')
@auth.login_required
def private_timeline():
    return Response()

@app.route('/secret/')
@auth.admin_required
def secret_area():
    return Response()


admin.setup()
api.setup()
예제 #8
0
def setup_api(auth):
    user_auth = UserAuthentication(auth)
    api = RestAPI(app, default_auth=user_auth)
    api.register(User, UserResource)
    api.setup()
    return api
	enfermeiro = ForeignKeyField(Enfermeiro, related_name='pacientes', null=True)
	sala = ForeignKeyField(Sala, related_name='pacientes', null=True)
	modeloAgendamento = ForeignKeyField(ModeloAgendamento, null=True)

class AvaliacaoEscalaBraden(db.Model):
	paciente = ForeignKeyField(Paciente, related_name='avaliacoes')
	sala = ForeignKeyField(Sala, related_name='avaliacoes')
	enfermeiro = ForeignKeyField(Enfermeiro, related_name='avaliacoes')
	data = DateTimeField();
	status = IntegerField()
	percepcaoSensorial = IntegerField()
	umidade = IntegerField()
	atividade = IntegerField()
	mobilidade = IntegerField()
	nutricao = IntegerField()
	friccao = IntegerField()

class Calendario(db.Model):
	dia = DateTimeField()

class CalendarioDetalhe(db.Model):
	calendario = ForeignKeyField(Calendario, related_name='detalhes')
	paciente = ForeignKeyField(Paciente)
	avaliacao = ForeignKeyField(AvaliacaoEscalaBraden, null=True)


restApi = RestAPI(app)
restApi.register(AvaliacaoEscalaBraden)
restApi.register(Sala)
restApi.setup()