Exemple #1
0
def server():
    # start app
    app = create_app()
    app.config['TESTING'] = True

    server = app.test_client()

    yield server
Exemple #2
0
def app():
    app = create_app({
        'TESTING': True,
        'SQLALCHEMY_DATABASE_URI': 'sqlite:///' + os.path.join(os.path.dirname(__file__), 'sql.db'),
        'SQLALCHEMY_TRACK_MODIFICATIONS': False,
        'API_MAX_PAGE_SIZE': 1000,
        'SEGMENT_SIZE_BP': 1000,
        'CACHE_ENABLED': False,
        'CACHE_REDIS_HOSTNAME': '127.0.0.1',
        'CACHE_REDIS_PORT': 6379
    })

    app.config['REFERENCES_JSON'] = os.path.join(os.path.dirname(__file__), 'datasets.json')

    from rest.model import load_references
    with app.app_context():
        load_references(app.config['REFERENCES_JSON'])

    yield app
Exemple #3
0
from rest import create_app
import os
from rest import api

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
api.init_app(app)

if __name__ == "__main__":
    try:
        app.run(port=5566)
    except Exception as e:
        print("error: {}".format(e))
        app.run(port=5567)
Exemple #4
0
import os.path

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

import rest

application = DispatcherMiddleware(rest.create_app(),
                                   {'/v1': rest.create_app()})

# For testing purposes, add a route that serves static files from a directory.
# DO NOT USE IN PRODUCTION. Serve static files through your webserver instead.
if application.app.config.get('DEBUG', False):
    from flask import send_from_directory

    @application.app.route('/data/<path:filename>')
    def download_dump(filename):
        collection_name = '_'.join(filename.split('_')[:2])
        base_dir = os.path.join(application.app.config.get('DUMPS_DIR'),
                                collection_name)
        return send_from_directory(base_dir, filename, as_attachment=True)

    @application.app.route('/media/<path:filename>')
    def serve_media(filename):
        base_dir = os.path.join(application.app.config.get('THUMBNAILS_DIR'),
                                os.path.dirname(filename))
        return send_from_directory(base_dir, os.path.basename(filename))


if __name__ == '__main__':
    run_simple('0.0.0.0',
"""
Startup da aprlicação.
"""
from rest import create_app

app = create_app('config.default')

if __name__ == "__main__":
    app.run(debug=True)
Exemple #6
0
def app():
    application = create_app("testing")

    application.app_context().push()

    return application
 def setUp(self):
     app = create_app('config')
     self.app = app.test_client()
     self.app.testing = True
     self.headers = [('Content-Type', 'application/json')]
from rest import create_app

rest = create_app()

if __name__ == '__main__':
    rest.run(host="0.0.0.0", port=5000)
import os.path

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

import rest

application = DispatcherMiddleware(rest.create_app(), {
    '/v1': rest.create_app()
})

# For testing purposes, add a route that serves static files from a directory.
# DO NOT USE IN PRODUCTION. Serve static files through your webserver instead.
if application.app.config.get('DEBUG', False):
    from flask import send_from_directory


    @application.app.route('/data/<path:filename>')
    def download_dump(filename):
        collection_name = '_'.join(filename.split('_')[:2])
        base_dir = os.path.join(application.app.config.get('DUMPS_DIR'),
                                collection_name)
        return send_from_directory(base_dir, filename, as_attachment=True)


    @application.app.route('/media/<path:filename>')
    def serve_media(filename):
        base_dir = os.path.join(application.app.config.get('THUMBNAILS_DIR'),
                                os.path.dirname(filename))
        return send_from_directory(base_dir, os.path.basename(filename))