Example #1
0
def app():
    """
    App fixtures used by pytest-tornado for things like http_client
    """
    _app_config = to_tornado_dict(TestConfig)
    _app = create_app(_app_config)
    return _app
Example #2
0
def app():
    _app = create_app(TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    yield _app

    ctx.pop()
Example #3
0
def app(request):
    """
    Flask app instance fixture with an active request context.
    See: http://flask.pocoo.org/docs/0.10/reqcontext/
    """
    _app = create_app(TestConfig)
    request.instance.app = _app

    ctx = _app.test_request_context()
    ctx.push()

    request.addfinalizer(ctx.pop)
    return _app
def app():
    """
    Yields a flask app instance with an active request context.

    We need to do this to get access to the request object for making HTTP requests.
    See: http://flask.pocoo.org/docs/0.10/reqcontext/
    """
    _app = create_app(TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    yield _app

    ctx.pop()
Example #5
0
 def create_app(self):
     app = ginsu.create_app()
     app.config['TESTING'] = True
     return app
Example #6
0
# /run.py
import os

from src.app import create_app

env_name = os.getenv('FLASK_ENV')

def get_env_variable(name):
    try:
        return os.environ[name]
    except KeyError:
        message = 'Expected environmecatnt variable {} not set.'.format(name)
        raise Exception(message)

# the values of those depend on your setup
POSTGRES_URL = get_env_variable('POSTGRES_URL')
POSTGRES_USER = get_env_variable('POSTGRES_USER')
POSTGRES_PW = get_env_variable('POSTGRES_PW')
POSTGRES_DB = get_env_variable('POSTGRES_DB')

DB_URL = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(user=POSTGRES_USER,pw=POSTGRES_PW,url=POSTGRES_URL,db=POSTGRES_DB)

app = create_app(env_name, DB_URL)

if __name__ == '__main__':
  port = os.getenv('PORT')
  # run app
  app.run(host='0.0.0.0', port=port)
Example #7
0
# /run.py
import os
from src.app import create_app
from src.config import app_config

app = create_app(app_config[os.environ.get('FLASK_ENV', 'development')])

if __name__ == '__main__':
    app.run(host=os.environ.get('APP_HOST', 'localhost'), port=os.environ.get('APP_PORT', 9874))
Example #8
0
from src.app import create_app
from src.db import *
import src.config as config


def create_roles():
    role1 = Role(name=Name("admin"))
    role1.save()

    role2 = Role(name=Name("user"))
    role2.save()

def create_admin_user():
    user = User(name=Name("Admin User"),
                email=Email("*****@*****.**"),
                role=Role.get_by_id(1))
    user.save()

if __name__ == "__main__":
    db.create_all(app=create_app(config))
    create_roles()
    create_admin_user()
                                                 path=path12)
    new_reference_document12.save()


if __name__ == "__main__":
    connection1 = MySQLdb.connect(host="localhost",
                                  user="******",
                                  passwd="root",
                                  db="old_outreach")
    cursor1 = connection1.cursor()

    connection2 = MySQLdb.connect(host="localhost",
                                  user="******",
                                  passwd="root",
                                  db="outreach")
    cursor2 = connection2.cursor()

    db.create_all(app=create_app(config))
    populate_users()
    populate_workshops()
    populate_nodal_centres()
    populate_nodal_coordinator_details()
    populate_workshop_reports()
    populate_reference_documents()

    cursor1.close()
    connection1.close()

    cursor2.close()
    connection2.close()
Example #10
0
from flask import Flask
from src import app
from config import config

layer = app.create_app()

if __name__ == '__main__':
	layer.config['SERVER_NAME'] = 'localhost:1338'
	layer.run(debug = True)
	layer.run()
Example #11
0
def runserver(*args):
    """ Serves Tornado App """
    app = create_app(app_config)
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(8000)
    tornado.ioloop.IOLoop.instance().start()
def test_test_config():
    app = create_app(TestConfig)
    assert app.config['ENV'] == 'test'
def test_dev_config():
    app = create_app(DevelopmentConfig)
    assert app.config['ENV'] == 'dev'
    assert app.config['DEBUG'] is True
Example #14
0
	def create_app(self):
		app = ginsu.create_app()
		app.config['TESTING'] = True
		return app
Example #15
0
def app() -> FastAPI:
    return create_app()
Example #16
0
 def create_app(self):
     app = create_app('testing')
     return app
Example #17
0
import os
from src.config import DATABASE_CONNECTION_URI
from src.app import create_app
from src.models import db

app = create_app('verse_api')
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_CONNECTION_URI
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.app_context().push()
db.create_all()

if __name__ == '__main__':
    app.run(host='0.0.0.0')
Example #18
0
 def create_app(self):
     return create_app()
Example #19
0
from src.app import create_app

app = create_app()
Example #20
0
# /run.py
import os
from src.app import create_app

env_name = os.environ['FLASK_ENV']
app_flask = create_app(env_name)


def mulai(environ, start_response):
    # run app
    """Simplest possible application object"""
    data = b'Hello, World!\n'
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(data)))]
    start_response(status, response_headers)
    return iter([data])


if __name__ == '__main__':
    app_flask.run()
        #exp.save()

    print "Done saving experiments.."


if __name__ == "__main__":

    # DB URI of the older database: from which we are migrating..
    # NOTE: the new DB URI: to which we are migrating is mentioned in the
    # config.py file under src/
    old_db_uri = 'mysql+oursql://root:vlabs123@localhost/vlabs_database'
    # old_db_uri = 'mysql+oursql://<username>:<password>@localhost/<db-name>'

    # instantiate a engine
    old_db = create_engine(old_db_uri)
    # get a connection
    conn = old_db.connect()

    # create the Flask-SQLAlchemy app
    app = create_app(config)

    # populate some data..
    populate_tech()
    populate_instt()
    populate_disc()
    populate_devs()
    populate_labs()
    populate_exps()

    conn.close()
Example #22
0
def app():
    container = TestAppContainer()
    app = create_app(container)
    return app
def test_production_config():
    app = create_app(ProductionConfig)
    assert app.config['ENV'] == 'prod'
    assert app.config['DEBUG'] is False
    assert app.config['ASSETS_DEBUG'] is False
def reports_app():
    app = create_app(config_class=TestConfig)
    return app.test_client(use_cookies=True)
Example #25
0
# -*- coding: utf-8 -*-
# encoding: utf-8
# /run.py
"""
                           API
    ------------------------------------------------------------------------
                         Initialize server
    ------------------------------------------------------------------------

"""
import os
from dotenv import load_dotenv, find_dotenv

from src.app import create_app

load_dotenv(find_dotenv(filename='.env'))

app = create_app(os.getenv('FLASK_ENV'))

if __name__ == '__main__':
    port = os.getenv('APP_PORT')
    host = os.getenv('APP_HOST')
    # run app

    app.run(host=host, port=port)
Example #26
0
import click
from sqlalchemy.exc import IntegrityError

from src.app import create_app
from src.database import (
    db,
    User,
    Chat,
    YandexDiskToken,
    UserQuery,
    ChatQuery,
    YandexDiskTokenQuery
)


app = create_app("development")


class PossibleInfiniteLoopError(Exception):
    """
    Indicates that loop probably become an infinite.
    Because of this dangerous loop a script runtime was interrupted.
    """
    pass


class InvalidTableDataError(Exception):
    """
    Indicates that table in DB is invalid
    (data is empty, some required data is NULL, etc.)
    """
Example #27
0
# /run.py

import os

from src.app import create_app

if __name__ == '__main__':
    app = create_app(os.getenv('APP_SETTINGS'))
    # run app
    app.run()
Example #28
0
from src.data import models
from src.util import invoke_process, parse_sqlalchemy_url


def import_env():
    if os.path.exists('.env'):
        print 'Importing environment from .env...'
        for line in open('.env'):
            var = line.strip().split('=', 1)
            if len(var) == 2:
                os.environ[var[0]] = var[1]


import_env()

app = create_app(app_config)
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
manager = Manager(app)
test_manager = Manager(usage='Performs test related operations')

manager.add_command('db', db_manager)
manager.add_command('test', test_manager)
manager.add_command("routes", ShowUrls())


@manager.shell
def make_context_shell():
    """
    Usage: ./manage.py shell
    Starts a python shell with with app, db and models loaded
    """
Example #29
0
from flask import Flask
from src import app
from config import config

ginsu = app.create_app()

if __name__ == '__main__':
    ginsu.config['SERVER_NAME'] = 'localhost:1111'
    ginsu.run(debug=True)
Example #30
0
# /run.py
import os
from src.app import create_app

if __name__ == '__main__':
  environment_selected = os.getenv('FLASK_ENV') # $export FLASK_ENV=development
  app = create_app(environment_selected)
  app.run()  # run app
Example #31
0
import os

from src.app import create_app

if __name__ == '__main__':

    app = create_app('development')
    app.run()
Example #32
0
import os
from src.app import create_app


if __name__ == '__main__':
    env_name = os.getenv('FLASK_ENV')   # get the environment (development/production) from env variables)
    print(env_name)
    app = create_app(env_name)          # create the app with the corresponding environment
    port = os.getenv('PORT')
    app.run(host='0.0.0.0', port=8080)                           # run the app
Example #33
0
 def create_app(self):
     app = create_app(config)
     return app
Example #34
0
 def setUp(self):
     self.app = create_app('test')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Example #35
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from src.extensions import db
from src.app import create_app
from src.config.config import Config
from src.models import *

app = create_app(Config)
db.init_app(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
import os
from src.app import create_app

env = os.environ.get('APP_ENV', 'dev')
app = create_app(env)

if __name__ == '__main__':
    app.run(debug=True, threaded=True, port=8000)
Example #37
0
# -*- coding: utf-8 -*-

import sys
sys.path.append('.')
from src.models.post import Post
from src.app import create_app
from src.config.config_dev import DevConfig
from flask.globals import _app_ctx_stack

test_post1 = Post(1, "测试标题1", "测试正文1", id=1)
test_post2 = Post(1, "测试标题2", "测试正文2", id=2)

if not _app_ctx_stack.top:
    app = create_app(DevConfig)
    ctx = app.app_context()
    ctx.push()

    test_post1.save()
    test_post2.save()

    _app_ctx_stack.pop()
Example #38
0
from src.app import create_app
from src.settings import DevConfig

app = create_app(config_object=DevConfig)

if __name__ == '__main__':
    """Main Application
    python manage.py
    """
    app.run(host='127.0.0.1', port=5000, threaded=True, use_reloader=True)

Example #39
0
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from src.app import create_app, db

env_name = os.getenv('FLASK_ENV')
app = create_app(env_name)
migrate = Migrate(app=app, db=db)
manager = Manager(app=app)

manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
Example #40
0
import os
from src.app import create_app  


try:
    print("INITIALIZING APP")
    app = create_app(os.getenv('ENV') or 'DEV') 
except Exception as exc:
    # Intercept exception to record it and re-raise it
    print(f"ERROR INITIALIZING APP: {exc}")
    raise exc
Example #41
0
from flask import Flask
from src import app
from config import config

ginsu = app.create_app()

if __name__ == '__main__':
    ginsu.config['SERVER_NAME'] = 'localhost:1111'
    ginsu.run(debug=True)
Example #42
0
"""
Initialize Flask app

:author: Almer Mendoza <*****@*****.**>
"""

from src.app import create_app
import src.config as config

from dotenv import load_dotenv
from pathlib import Path

env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)

import os

config_object = eval(os.environ['FLASK_APP_CONFIG'])
app = create_app(config_object)
Example #43
0
 def create_app(self):
     app = create_app(config)
     return app
Example #44
0
 def setUpClass(cls):
     app = create_app('test')
     app.app_context().push()
     db.init_app(app)
     cls.request = app.test_client()
Example #45
0
#!/usr/bin/env python
"""
Used for serving the application via gunicorn in heroku.
See Procfile for commands
"""
from src.app import create_app
from src.settings import app_config

flask_app = create_app(app_config)
def test_test_config():
    app = create_app(TestConfig)
    assert app.config['ENV'] == 'test'
    assert app.config['TESTING'] is True