コード例 #1
0
ファイル: __init__.py プロジェクト: paulmetzger/Hegemone
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    #Set database up
    engine = create_engine(
        'sqlite:///../database/hegemone_dev.sqlite3',
        echo=False,
        #Avoid exception caused by sqlites poor support of multithreading.
        #This needs to be removed if the system is used by many users and when
        #another database is used.
        connect_args={'check_same_thread': False},
        poolclass=StaticPool)
    db.setup_db(engine)
    Session = sessionmaker(bind=engine)
    session = Session()

    #Set repositories up
    website_repository = WebsiteRepository(session)
    word_count_repository = WordCountRepository(session)

    #Set business logic layer up
    businessLogicLayer.websites.website_repository = website_repository
    businessLogicLayer.wordCounts.word_count_repository = word_count_repository

    #Set webserver up
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.add_static_view('static', 'static', cache_max_age=3600)
    routes.set_routes(config)
    config.scan()
    return config.make_wsgi_app()
コード例 #2
0
    def init_app(self, config_name):
        app = Flask(__name__,
                    instance_relative_config=True,
                    static_folder='../../static/dist',
                    template_folder='../../static')
        app.config.from_object(app_config[config_name or 'production'])
        app.config.from_pyfile('config.py')

        self.db = get_db(app)
        self.init_login_manager(app)

        from routes import set_routes
        set_routes(app)
        migrate = Migrate(app, self.db)
        self.db.create_all()
        self.db.session.commit()

        return app
コード例 #3
0
import sys
import asyncio
import logging

from aiohttp import web
from routes import set_routes
from models import set_db, close_db
from middleware import check_auth

if sys.platform.startswith('win'):
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

app = web.Application()

set_routes(app)

app.on_startup.append(set_db)
app.on_cleanup.append(close_db)

app.middlewares.append(check_auth)

logging.basicConfig(level=logging.DEBUG, filename='log.log')

web.run_app(app)
コード例 #4
0
ファイル: manage.py プロジェクト: alisonbnt/flask-demo
from flask_script import Manager, Server
from app import app
from routes import set_routes

manager = Manager(app)
set_routes()

# Turn on debugger by default and reloader
manager.add_command("runserver", Server(
    use_debugger = True,
    use_reloader = True,
    host = '0.0.0.0')
)

if __name__ == "__main__":
    manager.run()
コード例 #5
0
from aiohttp import web

from routes import set_routes
from classifier import MultiClassifier
from sklearn.datasets import fetch_20newsgroups

app = web.Application()
routes = set_routes()
app.add_routes(routes)
train_dataset = fetch_20newsgroups(subset='train',
                                   remove=('headers', 'footers', 'quotes'))
app['multiclassifier'] = MultiClassifier(train_dataset.data,
                                         train_dataset.target,
                                         train_dataset.target_names)

if __name__ == '__main__':
    web.run_app(app)