コード例 #1
0
ファイル: wsgi.py プロジェクト: NickWoodhams/trello_to_slack
    ~~~~

    straply wsgi module
"""

# auto Alembic
import sys
from os.path import dirname, abspath
sys.path.append(dirname(dirname(abspath(__file__))))
from subprocess import Popen, PIPE, STDOUT

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

from straply import api, frontend, restless

application = DispatcherMiddleware(frontend.create_app(), {
    '/api': api.create_app(),
    '/restless': restless.create_app()
})

if __name__ == "__main__":

    # Preform Database Upgrades Automatically :)
    command = '''
        alembic upgrade head
    '''
    Popen(command, shell=True)

    run_simple('0.0.0.0', 9360, application, use_reloader=True, use_debugger=True)
コード例 #2
0
ファイル: env.py プロジェクト: NickWoodhams/straply
    roxor
"""
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig

import sys
from os.path import dirname, abspath
sys.path.append(dirname(dirname(abspath(__file__))))

from straply.core import db
from straply.models import *
from straply.frontend import create_app

app = create_app()

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.

def run_migrations_offline():
コード例 #3
0
ファイル: wsgi.py プロジェクト: NickWoodhams/straply
    straply wsgi module
"""

# auto Alembic
import sys
from os.path import dirname, abspath
sys.path.append(dirname(dirname(abspath(__file__))))
from subprocess import Popen, PIPE, STDOUT

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

from straply import api, frontend, restless

frontend_app = frontend.create_app()
api_app = api.create_app()
restless_app = restless.create_app()


@frontend_app.before_first_request
def setup_app():
    from straply.models import User, Role
    from straply.core import db
    db.create_all()
    if not Role.query.filter_by(name="admin").count():
        role = Role(name="admin")
        db.session.add(role)
        db.session.commit()
    else:
        role = Role.query.filter_by(name='admin').first()