How to use the eve.Eve function in Eve

To help you get started, we’ve selected a few Eve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MongoEngine / eve-mongoengine / tests / __init__.py View on Github external
def setUpClass(cls):
        SETTINGS['DOMAIN'] = {'eve-mongoengine':{}}
        app = Eve(settings=SETTINGS)
        app.debug = True
        ext = EveMongoengine(app)
        ext.add_model([SimpleDoc, ComplexDoc, LimitedDoc, FieldsDoc,
                       NonStructuredDoc, Inherited, HawkeyDoc])
        cls.ext = ext
        cls.client = app.test_client()
        cls.app = app
github dfci / matchminer-api / tests / test_matchminer / __init__.py View on Github external
# create the engine.
        self.cbio = engine.CBioEngine(MONGO_URI,
                                      MONGO_DBNAME,
                                      data_model.match_schema,
                                      muser=MONGO_USERNAME,
                                      mpass=MONGO_PASSWORD,
                                      collection_clinical=COLLECTION_CLINICAL,
                                      collection_genomic=COLLECTION_GENOMIC)

        # setup the database.
        self.setupDB()

        # prepare the app
        self.settings_file = settings_file
        self.app = eve.Eve(settings=self.settings_file,
                           url_converters=url_converters,
                           auth=security.TokenAuth,
                           validator=ConsentValidatorEve)

        # create the test client
        self.test_client = self.app.test_client()

        # set domain.
        self.domain = self.app.config['DOMAIN']

        # register hooks
        self.app = register_hooks(self.app)

        # register blueprints.
        self.app.register_blueprint(blueprint)
github pyeve / eve-sqlalchemy / eve_sqlalchemy / examples / one_to_many / app.py View on Github external
from eve import Eve

from eve_sqlalchemy import SQL
from eve_sqlalchemy.examples.one_to_many.domain import Base, Child, Parent
from eve_sqlalchemy.validation import ValidatorSQL

app = Eve(validator=ValidatorSQL, data=SQL)

db = app.data.driver
Base.metadata.bind = db.engine
db.Model = Base

# create database schema on startup and populate some example data
db.create_all()
db.session.add_all([Parent(children=[Child() for k in range(n)])
                    for n in range(10)])
db.session.commit()

# using reloader will destroy the in-memory sqlite db
app.run(debug=True, use_reloader=False)
github pyeve / eve-sqlalchemy / eve_sqlalchemy / examples / many_to_one / app.py View on Github external
from eve import Eve

from eve_sqlalchemy import SQL
from eve_sqlalchemy.examples.many_to_one.domain import Base, Child, Parent
from eve_sqlalchemy.validation import ValidatorSQL

app = Eve(validator=ValidatorSQL, data=SQL)

db = app.data.driver
Base.metadata.bind = db.engine
db.Model = Base
db.create_all()

children = [Child(), Child()]
parents = [Parent(child=children[n % 2]) for n in range(10)]
db.session.add_all(parents)
db.session.commit()

# using reloader will destroy in-memory sqlite db
app.run(debug=True, use_reloader=False)
github armadillica / flamenco / flamenco / server-eve / application / __init__.py View on Github external
v = Validator(node_type['dyn_schema'])
        val = v.validate(value)

        if val:
            return True

        log.warning('Error validating properties for node %s: %s', self.document, v.errors)
        self._error(field, "Error validating properties")


# We specify a settings.py file because when running on wsgi we can't detect it
# automatically. The default path (which works in Docker) can be overridden with
# an env variable.
settings_path = os.environ.get(
    'EVE_SETTINGS', '/data/git/pillar/pillar/settings.py')
app = Eve(settings=settings_path, validator=ValidateCustomFields)

# Load configuration from three different sources, to make it easy to override
# settings with secrets, as well as for development & testing.
app_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
app.config.from_pyfile(os.path.join(app_root, 'config.py'), silent=False)
app.config.from_pyfile(os.path.join(app_root, 'config_local.py'), silent=True)
from_envvar = os.environ.get('PILLAR_CONFIG')
if from_envvar:
    # Don't use from_envvar, as we want different behaviour. If the envvar
    # is not set, it's fine (i.e. silent=True), but if it is set and the
    # configfile doesn't exist, it should error out (i.e. silent=False).
    app.config.from_pyfile(from_envvar, silent=False)

# Set the TMP environment variable to manage where uploads are stored.
# These are all used by tempfile.mkstemp(), but we don't knwow in whic
# order. As such, we remove all used variables but the one we set.
github pyeve / eve / run.py View on Github external
from eve import Eve
from eve.io.mongo import Validator


class Validator(Validator):
    def _validate_cin(self, cin, field, value):
        if cin:
            pass


if __name__ == '__main__':
    app = Eve(validator=Validator)
    app.run()
github arcsecw / query_order / api / run.py View on Github external
from flask.ext.sentinel import ResourceOwnerPasswordCredentials, oauth
from flask import request
import json
from pymongo import MongoClient
from proj.tasks import add
import cPickle
from flask import  request,Response


# users = cPickle.load(open('./users.pd','r'))
users = []
client = MongoClient()
collect = client['eve']['orders']


app = Eve(auth=BearerAuth)
ResourceOwnerPasswordCredentials(app)
# app.debug = True
app.config['CORS_HEADERS'] = 'Content-Type'
cors = CORS(app)

@app.route('/query_order')
@oauth.require_oauth()
def query_order():
    a = Response("")
    a.headers['Access-Control-Allow-Origin'] = '*'

    if request.method=='POST':
        data = request.form
    else:
        data = request.values
github pyeve / eve / examples / security / token.py View on Github external
class TokenAuth(TokenAuth):
    def check_auth(self, token, allowed_roles, resource, method):
        """For the purpose of this example the implementation is as simple as
        possible. A 'real' token should probably contain a hash of the
        username/password combo, which should be then validated against the
        account data stored on the DB.
        """
        # use Eve's own db driver; no additional connections/resources are used
        accounts = app.data.driver.db["accounts"]
        return accounts.find_one({"token": token})


if __name__ == "__main__":
    app = Eve(auth=TokenAuth, settings=SETTINGS)
    app.run()
github twreporter / tr-projects-rest / server.py View on Github external
item['leading_video'] = filter_leading_video(item['leading_video'])
    return item

def before_returing_topics(response): 
    items = response['_items']
    for item in items:
        item = before_returning_topic(item)
    return response

def before_returning_topic(response):
    item = filter_topic(response)
    item = get_relateds(item, 'relateds')
    return item

#app = Eve(auth=RolesAuth)
app = Eve()
app.on_fetched_resource_meta += before_returning_meta
app.on_fetched_resource_posts += before_returning_posts
app.on_fetched_item_posts += before_returning_post
app.on_fetched_resource_topics += before_returing_topics
app.on_fetched_item_topics += before_returning_topic

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=8080, threaded=True, debug=True)
github jay3dec / REST_API_EVE_Part-1 / api.py View on Github external
user = user.find_one({'username': username,'password':password})
            
            if user:
                return True
            else:
                return False
        elif resource == 'user' and method == 'POST':
            print username
            print password
            return username == 'admin' and password == 'password'
        else:
            return True
            

if __name__ == '__main__':
    app = Eve(auth=Authenticate)
    app.run()